# How Top AI Companies Handle Context Engineering

> Comparative framework of context engineering strategies across six leading AI agent companies.

A comprehensive analysis by Himanshu comparing how Manus, Cursor, Anthropic, OpenAI, Google DeepMind, and LangChain manage finite context windows in autonomous agents. It breaks down architectural trade-offs between dynamic retrieval, KV-cache optimization, file-based memory, and token compaction. It serves as a practical architectural reference for developers designing long-running agent harnesses.

## The framework

Core problem: context windows are finite while agents generate tokens exponentially (a Manus task ~50 tool calls); smarter context management beats bigger windows.

MANUS (Context Engineering for AI Agents, Jul 2025): six principles — 1) KV-cache is sacred: keep prompt prefix stable, logs append-only, even reordered JSON keys invalidate cache (cached $0.30 vs $3/MTok). 2) Logit masking over tool removal: all tools stay in context, availability controlled at decoding time. 3) File system as extended memory: large observations to files, only references in context; compression must be reversible. 4) Attention manipulation via recitation: a living todo.md re-read each step keeps objectives in the high-attention end of context. 5) Preserve errors, don't clean them. 6) Structured variation against fixation (vary serialization/phrasing).

CURSOR (Dynamic Context Discovery, Jan 2026): five techniques — files as tool-output interface (read via tail/grep); chat-history files making lossy summarization lossless; skills as discoverable files found via search, not pre-loaded; lazy MCP tool loading (only names upfront, definitions on demand — 46.9% token reduction in A/B tests); terminal sessions saved as greppable files. Premise: models are now good enough to pull the context they need.

ANTHROPIC (Effective Context Engineering for AI Agents, Sep 2025; Effective Harnesses for Long-Running Agents, Jan 2026; code execution with MCP, Nov 2025): attention budget framing; Goldilocks system prompts (clear sections/XML headers, canonical examples, don't hard-code edge cases — avoids over-engineered 2K-word if-else prompts and vague 'be helpful'); just-in-time retrieval over pre-inference RAG; lean, non-overlapping tools; auto-compaction at 95% window capacity, initializer agent writes persistent requirements file; code execution over direct MCP tool calls; failure patterns = one-shotting complex projects and imperfect compaction transfer, fixed with structured planning files.

OPENAI (Agents SDK cookbooks: session memory Sep 2025, context personalization Dec 2025): trimming (keep last N — causes amnesia), compression (summarize with separate call — risk of summary drift), state-based long-term memory (profile + notes with precedence: latest input → session → global). Key distinction: state-based memory supports belief updates over fact accumulation; more deterministic than retrieval-based memory.

GOOGLE DEEPMIND (ReadAgent paper 2024 + Gemini long-context docs): 'just put it all in' — abundance bet with up to 2M tokens (research to 10M); evidence: Gemini learned to translate Kalamang (\<200 speakers) from in-context materials alone; context caching up to 75% cost reduction; progressive truncation; ReadAgent gist memory (20x effective context); many-shot in-context learning. Tension: still 15–47% performance drops as context grows.

LANGCHAIN (Context Engineering for Agents; The Rise of Context Engineering; Deep Agents): the write-select-compress-isolate taxonomy — Write (scratchpads, persistent state, filesystem); Select (RAG, grep/glob — retrieving the RIGHT context, not just most similar); Compress (measured 115K → 60K tokens via end-to-end summarization); Isolate (multi-agent, own windows, prevent context pollution); no-op tools as context engineering (Claude Code's todo tool is purely a planning strategy).

Industry consensus: file system as extended memory, dynamic retrieval, persistent plan files, keep error traces. Active disagreements: logit masking (Manus) vs lazy loading (Cursor) for tool overload; long vs lean context (Google vs everyone); frameworks vs raw primitives. Unsolved: session memory (no two companies alike) and context-engineering evaluation (no standard benchmarks).

## What it is for

- Design memory and context compaction architectures for long-running autonomous agents
- Optimize prompt caching and KV-cache hit rates to reduce agent operational costs
- Implement file-system-based memory patterns to prevent context window bloat
- Evaluate trade-offs between lazy tool loading, logit masking, and traditional RAG

## Key points

- Manus framework: KV-cache preservation, logit masking, and attention manipulation via persistent todo lists
- Cursor architecture: Filesystem tool outputs, greppable chat logs, and lazy MCP tool definition loading
- Anthropic patterns: Attention budgeting, Goldilocks system prompts, and auto-compaction triggers
- OpenAI memory models: State-based memory precedence and belief updating versus simple fact accumulation
- DeepMind context philosophy: Massive context window utilization, gist memory, and many-shot in-context learning
- LangChain taxonomy: Core write-select-compress-isolate framework for agent context boundaries
- Industry consensus analysis: Synthesis of converged patterns and unresolved agent evaluation benchmarks

## Pricing

Free

## Details

- Type: Framework
- Category: [AI](https://xiry.app/topics/ai.md)
- Open source: no
- Platforms: Web
- For: AI engineers and system architects building autonomous agent systems
- Tags: context engineering, ai agents, llm architecture, prompt caching, mcp

## Why it was saved

- [@himanshutwtxs, 15 February 2026](https://x.com/himanshutwtxs/status/2022984467380682856): A single researched comparison of the industry's context-engineering strategies, with the exact source posts, papers and cookbooks named for each company.

## Related

- [Agent Harness is the Real Product](https://xiry.app/resources/agent-harness-is-the-real-product): Architectural breakdown of AI agent harnesses, scaffolds, and context management patterns. (Framework, Free)
- [ai-engineering-hub](https://xiry.app/resources/ai-engineering-hub): Open-source tutorials and project templates for LLMs, RAG, and AI agents. (GitHub repo, Open source)
- [Inspo](https://xiry.app/resources/inspo): Design inspiration MCP server and archive for AI coding agents. (Web app, Free)
- [Agent Reach](https://xiry.app/resources/agent-reach): Open-source capability layer giving AI agents access to browse and scrape platforms (GitHub repo, Open source)
- [awesome-claude-skills](https://xiry.app/resources/awesome-claude-skills): Curated collection of skills, tools, and plugins for Claude workflows (GitHub repo, Open source)
- [Monid](https://xiry.app/resources/monid): Pay-per-call tool discovery and API integration platform for AI agents (Web app, Freemium)

Updated 11 October 2026. Page: https://xiry.app/resources/how-top-ai-companies-handle-context-engineering

Make your own library: Xiry takes your saved reels, tweets, Reddit bookmarks and Watch Later videos, makes them searchable and pulls the useful stuff out, like this library. It's invite-only for now; join the waitlist at https://xiry.app/#waitlist.
