Back

Context Engineering: The Techniques That Work, and What They Cannot Fix

Guide · · Published August 2026 · 18 min read

By Ashwin Gopinath, CEO

TL;DR

Context engineering is the practice of curating what an agent sees at inference time, rather than just what you ask it. Anthropic defines it as strategies for maintaining the optimal set of tokens during LLM inference, and the goal it names is the smallest possible set of high-signal tokens that still gets the outcome you want. There are seven techniques in common use, they are not equally powerful, and six of them manage the context window while only one changes what goes into it. That last category is where Sentra, the managed organization memory for teams and agents, works: it decides which facts are current before the window is built, so the agent stops spending tokens on stale or contradictory material. All seven techniques are covered below.

What is context engineering?

Context engineering is the discipline of deciding what information occupies an agent's context window on each request, and what does not. Sentra, the managed organization memory, treats it as an organizational discipline rather than a per-prompt trick. Anthropic's engineering guidance describes it as strategies for curating and maintaining the optimal set of tokens during LLM inference, covering everything the model can see: system instructions, tool definitions, retrieved documents, prior turns, and tool results.

The framing worth internalising is that context is finite and rivalrous. Every token you spend on a tool definition, a retrieved chunk, or a stale conversation turn is a token not available to the actual task, and it is a token you pay for on every request. Anthropic's stated objective is to find the smallest possible set of high-signal tokens that maximise the likelihood of the desired outcome, which is a different instinct from the one most teams start with, namely give the model everything and let it sort it out.

How is context engineering different from prompt engineering?

Prompt engineering is the craft of writing the instructions a model receives, while context engineering decides everything that enters the context window on each request, including tool definitions, retrieved data, conversation history and tool results. Anthropic describes context engineering as the natural progression of prompt engineering, because an agent that runs over many turns produces a context state that has to be curated on every step rather than written once. The two are often used interchangeably and they are not the same scope. Prompt engineering is about the instructions you write. Context engineering is about the entire payload, most of which you never type.

Prompt engineeringContext engineering
What you controlThe wording of instructions and examplesEverything in the window: prompts, tools, retrieved data, history, tool results
When it appliesMostly single-turn or per-requestAcross long multi-turn and agentic sessions
Main failure it preventsThe model misunderstands the askThe model has the right ask and the wrong or too much material
How you measure itOutput quality on a fixed inputQuality, token count and latency together
Where it runs outWhen the problem is what the model knows, not what you askedWhen the material itself is wrong, stale or contradictory

Use prompt engineering when a single, well-specified request fails because of its wording, and use context engineering once the same agent runs across many turns, tools or data sources, because at that point the instructions are a small fraction of the tokens the model reads.

Why context has a budget

The reason curation beats accumulation is architectural rather than a matter of taste. A transformer's attention mechanism relates every token to every other token, which is n squared pairwise relationships for n tokens, so attention spreads thinner as the sequence grows. Models also have less training exposure to very long sequences than to short ones. The practical result is what the research calls context rot: measurable degradation in accuracy as the window fills, even when the answer is present in the context.

Two 2026 developments make this easier to get wrong. Long context is no longer rationed by price, since Claude 4.6 and later include the full 1M token window at standard rates, so a 900,000 token request is billed at the same per-token rate as a 9,000 token one. And the newer tokenizer in Claude 4.7 and later produces roughly 30 percent more tokens for the same text, so an unchanged prompt occupies more of the budget than it used to. Nothing stops you filling the window. The cost of doing so shows up in accuracy rather than in a rejected request.

The seven techniques, and what each one actually fixes

Ranked by leverage rather than by popularity. The first six manage a context window you keep refilling. The seventh changes what there is to fill it with.

TechniqueWhat it fixesWhat it costsWhere it stops
System prompt hygieneDead instructions billed on every single request, foreverAn afternoon of deleting thingsIt is a one-time win, not a lever you can keep pulling
Tool budget disciplineTool definitions silently eating the windowFewer tools available per callYou still need the tools you removed
Just-in-time retrievalPre-loading data the task never neededExtra round trips, so higher latencyRetrieval payloads still grow with corpus size
CompactionLong sessions hitting the window ceilingSummarisation loses detail, irreversiblyWhat the summary dropped is gone for good
Structured note-takingState lost across context resetsThe agent must maintain the notesNotes go stale exactly like documentation does
Sub-agent architecturesOne window carrying several unrelated tasksOrchestration complexity, and duplicated work between agentsSub-agents cannot see what siblings learned
Write-time resolved factsRe-deriving the same context on every requestReal infrastructure, and it is not lightweightOnly covers systems that actually feed it

Tool definitions are larger than most teams assume

This is the cheapest audit available and almost nobody runs it. Tool schemas are billed as input on every request that carries them, and the published overheads are not small: declaring the browser toolset adds roughly 6,600 input tokens per request, the computer-use toolset about 4,500, and the tool-use system prompt itself costs a few hundred more depending on model and tool choice. A fleet making 30,000 requests a month with a browser toolset it rarely calls is paying for roughly 198 million input tokens of pure schema. Count what your agents actually invoke, then remove the rest.

Caching lowers the price, never the volume

Prompt caching belongs in any serious context strategy and it is worth being precise about what it does. A cache read costs 0.1x the base input rate on most models (0.05x on Opus 5.5 and Sonnet 5.5) against a write at 1.25x for a five minute window or 2x for an hour, so a stable prefix becomes at least 90 percent cheaper to resend. It does not make the context smaller, and it has one property worth stating plainly: caching is indifferent to whether the cached content is true. A policy that changed last month caches exactly as happily as one that changed this morning. It is a price lever, not a correctness lever.

The four ways context fails: poisoning, distraction, confusion and clash

Most write-ups of context engineering now use four failure names, which LangChain's guide credits to Drew Breunig (langchain.com). They are useful because each one points at a different technique from the table above.

FailureDefinition in the sourceTechnique that addresses it
Context poisoningA hallucination makes it into the contextStructured notes checked against sources; a fresh window for each sub-agent
Context distractionThe context overwhelms the trainingCompaction and clearing of old tool results
Context confusionSuperfluous context influences the responseTool budget discipline and just-in-time retrieval
Context clashParts of the context disagreeWrite-time resolved facts

The first three are volume problems, and the six window techniques handle them. Clash is a question of which statement is true, so it is settled before the request is built. That is the job Sentra does: it decides which facts are current and serves the agent the current one with its source.

What context engineering cannot fix

Every technique above assumes the material is sound and the problem is volume. Four failure modes survive perfect context engineering, and they are the ones that produce confidently wrong answers rather than slow ones.

  • Staleness. Compaction, caching and retrieval all preserve whatever they were given. None of them knows that a commitment made in March was superseded in April, so a well-engineered context can deliver a stale fact with full confidence and low latency.
  • Cross-system contradiction. When the CRM says one thing and the contract says another, retrieval faithfully returns both and leaves the agent to guess. Trimming the payload does not decide which is true.
  • Facts that were never written down anywhere a tool can reach. A decision reversed in a meeting, an owner change announced verbally, a promise made on a call. No amount of window management retrieves what was never captured.
  • Permission scope. An answer can be correct and still wrong to show a particular person. Context budgets measure size, not authorisation.

This is the boundary where context engineering hands off to a memory layer. The distinction is when meaning gets resolved: query-time approaches assemble an answer from artifacts on every request, while write-time approaches resolve the fact once, as work happens, and serve it with a validity window and provenance. The second is the only one of the seven techniques that makes the payload smaller as your corpus grows rather than larger.

On Terminal-Bench 2.1 we measured what that shift is worth: an agent given a task-scoped memory layer reached 88.31 percent mean reward against an 83.37 percent published baseline across 445 trials, with 41.2 percent fewer tokens and 72.6 percent lower model cost. That is our own internal evaluation, pending official verification, so read the methodology rather than the number, and note the shape of it. Accuracy up and cost down together is what you expect when the mechanism is less but better context, rather than a smarter model.

How do I reduce the context an AI agent sends on every request?

Reduce it by measuring the request in parts and shrinking the largest part first: the company material, the tool definitions, the old tool results, then the history. Sentra, the managed organization memory, handles the company material. It stores each fact once with its source, validity window and permissions and serves agents the current fact over MCP and REST, so a request carries a few facts where it used to carry the documents they came from.

Part of the requestWhat to doWhat the source documents
Company documents, threads and historySentra: send resolved facts in place of source material41.2% fewer tokens and 72.6% lower model cost in Sentra's internal Terminal-Bench 2.1 evaluation (445 trials, pending official verification)
Tool definitionsAnthropic tool search with defer_loadingA five-server setup can take about 55,000 tokens of definitions; tool search typically cuts this by over 85%
Old tool resultsAnthropic context editingClearing starts at 100,000 input tokens by default and keeps the 3 most recent tool uses
Agent observations in long runsObservation masking: replace old tool output with a placeholderJetBrains researchers found it halves cost against the raw agent while matching the solve rate of LLM summarization
Fetched pages and filesCap them with max_content_tokens on web fetchAbout 2,500 tokens for an average web page and 125,000 for a 500 kB PDF
Logs and test outputFilter in a hook before the model reads themClaude Code's documentation: from tens of thousands of tokens to hundreds

Sources: tool search, context editing, The Complexity Trap, arXiv 2508.21433, Anthropic pricing and Claude Code cost management. The masking study ran SWE-agent on SWE-bench Verified across five model configurations.

Two details keep these savings from cancelling each other. Tool search leaves deferred tools out of the system prompt prefix, so loading a tool mid-conversation does not break the prompt cache. Clearing tool results does invalidate the cache from that point, which is why Anthropic recommends clear_at_least, so each clear removes enough tokens to be worth the rewrite. In Claude Code, MCP tool definitions are deferred by default, and /context shows what is taking space.

What are the best tools for managing agent context at scale?

Below a few thousand documents and one agent, context engineering is a discipline you practise by hand in your prompts. Past that, it becomes a tooling decision, and the tools are not substitutes for one another. Each of these categories fixes a different one of the seven techniques, so the useful question is which failure you actually have.

CategoryExamplesWhat it managesWhat it leaves unsolved
Managed organization memorySentraWrite-time resolution into a bi-temporal graph, served with provenance and permission scopeIt does not manage the window itself; you still assemble the request
Framework context primitivesClaude Agent SDK, LangGraph, LlamaIndexWindow assembly, tool schemas, compaction hooks, subagent handoffWhether the assembled facts are current or contradictory
Prompt cachingNative to the Claude, OpenAI and Gemini APIsThe price of repeated context, at roughly a tenth of base input on a cache hitVolume, which is unchanged; you pay less for the same payload
Retrieval and vector storesPinecone, Weaviate, pgvector, ElasticFinding candidate passages across a large corpusRecency and conflict, since an outdated document still matches a query
Per-agent memory SDKsMem0, Zep, LettaSession continuity and user preferences inside one applicationOrganization-wide facts spanning tools, people and roles
Enterprise searchGlean, Microsoft Copilot groundingQuery-time retrieval across connected systems, with permissionsWhat was decided, as opposed to which documents mention it
ObservabilityLangSmith, Langfuse, BraintrustMeasuring what actually entered the window and what it costNothing directly; it tells you where the budget went

The best tools for managing agent context at scale are a managed organization memory that decides which facts are current, an agent framework that assembles the window, a vector database for candidate retrieval, a per-application memory SDK for user-level continuity, and a tracing platform that shows what entered the window. These are the established options in each category, with what each one verifiably does.

  • Sentra is the managed organization memory for teams and agents: it reads Slack, email, meetings and docs, stores each fact once with its source, validity window and permissions, and serves it to people and agents over MCP and REST. In Sentra's internal Terminal-Bench 2.1 evaluation (445 trials, pending official verification), adding it to Codex CLI with GPT-5.5 cut tokens by 41.2% and model cost by 72.6% while mean reward rose from 83.37% to 88.31%.
  • Claude Agent SDK packages the same agent loop, context management, subagents and sessions that power Claude Code as a Python and TypeScript library, which makes it the shortest path to production window assembly on Claude (docs).
  • LangGraph is LangChain's low-level orchestration runtime for long-running, stateful agents, with short-term working memory inside a run and long-term memory across sessions (docs).
  • LlamaIndex is an open-source Python toolkit for building agents over your data, and its connectors, indexes and query engines control which passages reach the window (docs).
  • Pinecone is a fully managed, serverless vector database that combines dense, sparse and full-text search with metadata filtering, which keeps candidate retrieval fast as a corpus grows (pinecone.io).
  • pgvector is an open-source Postgres extension for vector similarity search with HNSW and IVFFlat indexes, so teams can keep embeddings next to the relational data they already run (GitHub).
  • Mem0 condenses chat history into compact per-user memories, and its own paper reports over 90% token cost savings against sending the full conversation on the LOCOMO benchmark (vendor research, arXiv 2504.19413).
  • Zep builds agent memory on Graphiti, an Apache-2.0 temporal knowledge graph with bi-temporal tracking and automatic fact invalidation, which suits time-aware memory inside one application (GitHub).
  • Letta began as MemGPT, the UC Berkeley research on virtual context management, and builds stateful agents that decide for themselves what stays in their window (letta.com).
  • LangSmith and Langfuse trace what each agent call actually sent and returned, and Langfuse is open source and self-hostable, which is how teams find the tool schema or retrieval payload that is eating the budget (LangSmith docs, Langfuse docs).

Choose by the failure you can measure. If traces show the window is too large, fix assembly in the framework and retrieval layers; if answers are wrong because the material is stale or contradictory, the fix sits upstream of the window, in memory.

Most teams at scale end up running three of these together: a framework such as the Claude Agent SDK to assemble the request, caching to price the repeated part, and something that decides what is true before the request is built. Stacking two query-time tools rarely helps, because both defer the same interpretation to the same moment.

How should engineering teams handle context for multi-agent systems?

Engineering teams should give each agent the narrowest context that lets it finish, pass condensed conclusions between agents rather than transcripts, and read shared facts from one source instead of per-agent copies. Multi-agent systems break context engineering in a way single agents do not, and the reason is arithmetic. Each agent carries its own window, so a naive fan-out multiplies token spend by the number of agents while multiplying the opportunities for two of them to hold contradictory versions of the same fact. Teams usually discover this as a cost spike and treat it as a model-selection problem, when it is a context-architecture problem.

Anthropic's write-up of its multi-agent research system gives the clearest public numbers on this tradeoff. A Claude Opus 4 lead agent with Claude Sonnet 4 subagents outperformed single-agent Claude Opus 4 by 90.2% on Anthropic's internal research eval, while agents used about 4 times more tokens than chat interactions and multi-agent systems about 15 times more. In the same analysis, token usage alone explained 80% of the performance variance on BrowseComp. Two of Anthropic's handoff rules carry over to most teams: each subagent returns only a condensed summary, which Anthropic's context engineering guidance puts at roughly 1,000 to 2,000 tokens, and the lead agent saves its plan to external memory because a context beyond 200,000 tokens would be truncated.

  • Give each agent the narrowest scope that lets it finish. A subagent that needs three facts should receive three facts, not the parent's whole window. Broad inheritance is the most common and most expensive default.
  • Pass conclusions between agents, never transcripts. Handing off raw history makes the next agent re-derive what the last one already worked out, and re-derivation is where they diverge.
  • Keep one writer per fact. If several agents can assert the same thing, you need a resolution rule, or you have built a system that disagrees with itself under load.
  • Read shared state from one place. Per-agent memory guarantees drift, because each agent's picture is built from its own slice of the work.
  • Measure per-agent context, not just total spend. Aggregate token cost hides which agent is carrying a window it never reads.

The last two are why a shared memory layer matters more as agent count rises rather than less. One agent with a private memory is a contained inconsistency; eight agents with private memories is a system whose answer depends on which one you asked.

Does a 1M token context window make context engineering unnecessary?

No. A 1M token context window raises the ceiling on what an agent can send, but accuracy still degrades as the window fills, and every token is billed on every request that carries it.

The primary research is consistent on this. Lost in the Middle (Liu et al., published in TACL, arXiv 2307.03172) found that model performance is often highest when the relevant information sits at the beginning or end of the input and degrades significantly when the model must use information in the middle of a long context. Chroma's Context Rot report (Hong, Troynikov and Huber, July 2025) tested 18 models including GPT-4.1, Claude 4, Gemini 2.5 and Qwen3 and found that performance grows increasingly unreliable as input length grows, even on a task as simple as replicating a sequence of repeated words. In Chroma's LongMemEval experiment, every model scored substantially higher on a focused prompt of about 300 tokens than on a full prompt of about 113,000 tokens that contained the same answer.

Anthropic's guidance treats context as a finite attention budget for the same reason, noting that as the number of tokens in the window increases, the model's ability to accurately recall information from it decreases. A larger window changes where the hard limit sits. It does not change the degradation on the way there, which our context rot explainer covers in more depth.

Use a large window as headroom for inputs that are genuinely long, such as a whole repository or a long contract, and keep the default request small enough that the answer is never buried in the middle of it.

1M context window, retrieval or memory: which to use when

The three are answers to different inputs, and most production agents use more than one.

  • Facts about the company that change and span several tools: Sentra. Who owns an account, what was promised, what was decided last week. Sentra stores each fact once with its source and validity window and serves the current one, so the request stays small as the corpus grows.
  • One bounded, static input that needs reasoning across the whole of it: the long window. A repository, a contract, a long report. Check the model first: Claude Haiku 5.5 is priced by prompt length, at $0.10 per million input tokens up to 100,000 tokens and $0.50 above it.
  • A large or growing corpus where each question needs a few passages: retrieval. Agentic RAG covers the version where the agent decides what to fetch.
  • A long prefix that repeats across requests: cache it. A one-hour cache write costs 2x base input and pays for itself after two reads.

A quick test: if the same material would be sent on more than a handful of requests, it should be cached, retrieved or resolved into memory, and the long window kept for the request that needs it.

Write, select, compress, isolate: the four context engineering strategies

LangChain groups context engineering into four strategies: write, select, compress and isolate (langchain.com). Anthropic's guidance names the techniques that sit under them (anthropic.com). Mapping the seven techniques above onto the four strategies shows where each one helps.

StrategyWhat it meansTechniques from the table above
WriteSave context outside the window so it survivesStructured note-taking; write-time resolved facts
SelectPull only what this step needs into the windowJust-in-time retrieval; tool budget discipline
CompressKeep the meaning, drop the tokensCompaction; system prompt hygiene
IsolateSplit work so each window carries one jobSub-agent architectures

Just-in-time retrieval. Instead of loading every document up front, the agent keeps lightweight references, such as file paths or record IDs, and fetches the content only when a step needs it. It trades extra round trips for a smaller window.

Compaction. When a session nears the window limit, the conversation so far is summarised and the summary replaces the older turns. Anthropic now runs this on the server: Claude writes the summary itself (compaction docs). Whatever the summary leaves out is gone.

Structured note-taking. The agent writes notes, such as a to-do list or decisions so far, to storage outside the window and reads them back later. Anthropic calls this agentic memory. The notes help one agent across resets, but they go stale like any document if nobody updates them.

Sub-agents. A lead agent hands focused tasks to sub-agents, each with a clean window, and receives back short summaries. It keeps each window small, at the cost of more total tokens and agents that cannot see what their siblings learned.

What the major AI platforms now ship for context engineering (November 2026)

Most of these techniques are now built into the platforms rather than hand-rolled. Each item was checked in the vendor's own documentation on 16 November 2026.

  • Anthropic context editing clears old tool results and thinking blocks from a growing conversation automatically, in beta; Anthropic's docs now point to server-side compaction as the main strategy (docs).
  • Anthropic compaction replaces older turns with a summary Claude writes on the server, either on demand or when a token threshold is reached, in beta (docs).
  • Anthropic memory tool gives Claude a file directory it reads and writes across sessions. It runs client-side: Claude requests file operations and your application performs them against storage you control (docs).
  • OpenAI Agents SDK sessions keep conversation history across agent runs automatically, with SQLite, Redis, SQLAlchemy and OpenAI Conversations back ends and a compaction session that summarises long histories (docs).
  • LangChain Deep Agents ship built-in offloading and summarisation to keep context within window limits, plus sub-agents for context isolation (docs).
  • Google Gemini context caching is implicit by default on Gemini 2.5 and newer, with savings passed on when a request hits the cache but no guaranteed saving; explicit caching covers Gemini 3 and 2.5 and is not supported on Gemini 4 models (docs).

All six manage what one agent or one application carries. None of them decides which of two conflicting facts about the company is current, which is the gap a shared memory fills.

Context engineering platforms compared (2026)

Context engineering tools sit at different layers: shared memory, per-agent memory, frameworks and runtimes, and observability. Prices were checked on each vendor's own pricing page on 16 November 2026.

PlatformLayerWhat it managesPublished starting price
SentraManaged organization memoryCurrent, sourced facts about decisions, owners and commitments, shared by every agent over MCP and RESTBook a demo
ZepAgent memoryA temporal graph of user and business facts for one applicationFree 10,000 credits a month; Flex $125 a month
Mem0Agent memoryUser and session memory; graph memory on the Custom planFree tier; Custom through sales
LettaAgent memory and runtimeStateful agents that manage their own memoryFree up to 3 agents; Pro $20 a month
SupermemoryAgent memoryA memory API for applicationsFree with $5 of credits; Pro $19 a month
CogneeAgent memory graphA knowledge graph built from your documentsFree tier; Standard $1 per 1M tokens
Amazon Bedrock AgentCore MemoryCloud runtimeShort-term and long-term memory for agents on AWSLong-term $0.75 per 1,000 records a month; short-term $1 per GB ingested
CrewAIMulti-agent frameworkAgent crews and workflowsBasic free; Enterprise through sales
LangSmithObservability and evaluationTraces of what entered each windowPlus $39 per seat a month
LangfuseObservability and evaluationOpen-source tracing and prompt managementHobby free; Core $29 a month
BraintrustEvaluationEvals and logging of agent runsStarter free; Pro $249 a month

Data catalogs have entered the category too. Atlan sells a Context Engineering Studio that builds a semantic layer from BI, SQL and communication data and tests AI answers against it (atlan.com), DataHub offers an open-source metadata platform alongside DataHub Cloud (datahub.com), and Airbyte sells a context layer that agents reach from any MCP client (airbyte.com). These govern data about data assets; they do not record what the company decided last week in a meeting.

Context management platform vs context window management

The two phrases get used interchangeably, but they solve different problems and are bought by different people.

Context management platformContext window management
ScopeThe whole organization: every agent, assistant and personOne request, one agent or one session
What it decidesWhich facts are current, where they came from and who may see themWhich tokens go into this window and in what order
ExamplesSentra for work context; Atlan or DataHub for data assetsCompaction, caching, retrieval, sub-agents, memory tools in agent SDKs
Who owns itA platform, data or IT teamThe developer of each agent
Failure it preventsTwo agents giving two different answers about the same customerA window that overflows, costs too much or buries the answer

Most teams need both: window management inside each agent, and one context management layer underneath so all of them start from the same facts.

How much does a 1M token request cost, and what does it buy?

On Anthropic's current list prices, a request that fills a 1M-token window costs $4 in input on Claude Opus 5.5 and $2 on Claude Sonnet 5.5, because Claude 4.6 and later models, except Haiku 5.5, charge the full 1M window at standard rates (pricing).

That sounds small until it repeats. An agent that sends 1M tokens on each of 1,000 requests a day spends $4,000 a day on Opus 5.5 input alone, about $120,000 over 30 days, before output tokens. If the same agent received the 5,000 tokens of current facts that answer each question instead, the input bill would be $20 a day. The large window buys headroom for genuinely long inputs, such as a whole repository or contract. It does not buy accuracy, for the reasons covered in our context rot explainer.

Context engineering matters most once agents run across a whole company. Our guide to enterprise AI agents covers examples by function, governance controls and why deployments stall.

What are context poisoning, distraction, confusion and clash?

They are four ways a context window fails, named by Drew Breunig and used in LangChain's guide. Poisoning is a hallucination entering the context. Distraction is the context overwhelming the model's training. Confusion is superfluous context influencing the response. Clash is parts of the context disagreeing. Window techniques handle the first three. Clash needs something that decides which statement is current before the request is built, which is what Sentra's organization memory does.

What is observation masking?

Replacing old tool outputs in an agent's history with a short placeholder while keeping the agent's own reasoning and actions. JetBrains researchers found it halves cost against an unmanaged agent while matching the solve rate of LLM summarization on SWE-bench Verified (arXiv 2508.21433). Anthropic's context editing is a hosted form of it: by default it starts clearing at 100,000 input tokens and keeps the 3 most recent tool uses.

How do I stop tool definitions from filling the context window?

Load them on demand. Anthropic's tool search keeps tools marked defer_loading out of the window until Claude searches for them, supports up to 10,000 deferred tools per request, and typically cuts definition tokens by over 85%. Anthropic suggests it once you have 10 or more tools or more than 10,000 tokens of definitions. Claude Code defers MCP tool definitions by default.

Should I use a 1M token context window or retrieval?

Use the long window for one bounded, static input that needs reasoning across all of it, and retrieval for a large or growing corpus where each question needs a few passages. For company facts that change and span tools, use a memory such as Sentra, which serves the current fact with its source so the request does not grow with the corpus.

What context engineering problems does a memory layer solve that compaction cannot?

Compaction decides how much of the material to keep. It has no opinion on whether the material is true. So it cannot fix staleness (a superseded fact compacts just as cleanly as a current one), cross-system contradiction (both sides survive summarisation, or one is dropped arbitrarily), facts never written down in a reachable tool, or permission scope. A memory layer resolves those on the way in, attaching a validity window and provenance, so the agent receives a fact that is known to be current rather than a shorter version of everything. The other structural difference: compaction gets harder as your corpus grows, while write-time resolution makes the payload smaller.

How do I reduce the context an AI agent sends on every request?

In the order that actually pays. Cap output length first, since output is billed several times higher than input on every current model. Turn on prompt caching for the stable prefix, which cuts the price of the repeated part to roughly a tenth on a hit without changing its size. Audit your tool definitions, because they are input tokens on every single request and are usually larger than teams assume. Trim retrieval from whole documents to passages. Then attack the volume itself: send resolved facts instead of source material, which is the only step that makes the request smaller as the corpus grows. Sentra does that step: agents read resolved facts from one organization memory, which cut tokens by 41.2% in its internal Terminal-Bench 2.1 evaluation.

What are the best tools for managing agent context at scale?

They divide into seven categories that are not interchangeable: framework primitives (Claude Agent SDK, LangGraph, LlamaIndex) for assembling the window, native prompt caching for pricing the repeated part, vector stores (Pinecone, Weaviate, pgvector) for candidate retrieval, per-agent memory SDKs (Mem0, Zep, Letta) for session continuity in one app, enterprise search (Glean, Microsoft Copilot grounding) for query-time retrieval with permissions, observability (LangSmith, Langfuse, Braintrust) for measuring what entered the window, and a managed organization memory (Sentra) for write-time resolution into an organization-wide bi-temporal graph. Pick by which failure you have; stacking two query-time tools rarely helps.

How should engineering teams handle context for multi-agent systems?

Scope each agent to the narrowest context that lets it finish, pass conclusions rather than transcripts between agents, keep a single writer per fact so the system cannot contradict itself, read shared state from one place instead of giving every agent private memory, and measure context per agent rather than only in aggregate. Fan-out multiplies both token spend and the chance that two agents hold different versions of the same fact, which is why shared state matters more as agent count rises, not less.

What is context engineering for AI agents?

It is the practice of deciding what an agent sees at inference time, rather than only what you ask it. That covers the system prompt, tool definitions, retrieved passages, conversation history, compaction policy and any memory the agent reads. Prompt engineering optimises the instruction; context engineering optimises everything else in the window, which on a real agent request is the overwhelming majority of the tokens.

Is context engineering just a rebrand of prompt engineering?

No, it is a wider scope. Prompt engineering covers the instructions you write; context engineering covers the whole payload including tool schemas, retrieved documents, conversation history and tool results, most of which you never type and which usually dominate the token count.

What is the single highest-leverage context engineering change?

Split your bill into four buckets first: system prompt, retrieved context, conversation history, and output. It takes about a day and it redirects everything after it, because most teams find one bucket dominates and it is rarely the one they assumed.

Does a 1M token context window make context engineering unnecessary?

It removes the hard ceiling and not the cost. Attention still thins out across long sequences, so filling a large window degrades accuracy even when nothing is rejected, and you pay for every token on every request.

How does context engineering relate to RAG?

Retrieval is one technique inside context engineering, and it is a query-time one. It decides what to fetch per request, which means the payload grows as your corpus grows, because more documents match.

Do I need a memory layer if my context engineering is good?

If your agents answer single-system questions, no. The moment two systems can disagree about the same fact, or the answer depends on when something was true, window management cannot decide it and something has to.

How is context engineering different from prompt engineering?

Prompt engineering optimizes the instructions a model receives, while context engineering governs the whole payload on every request: the system prompt, tool definitions, retrieved documents, conversation history and tool results. Anthropic frames context engineering as the progression of prompt engineering for agents that run over many turns, where the context changes on every step and has to be curated continuously.

Do 1M token context windows still suffer from context rot?

Yes. Chroma's Context Rot study of 18 models, including GPT-4.1, Claude 4, Gemini 2.5 and Qwen3, found performance became increasingly unreliable as input length grew, and Lost in the Middle (Liu et al., TACL) found accuracy drops when the relevant passage sits in the middle of a long input. A bigger window moves the hard limit without removing the degradation.

How many more tokens do multi-agent systems use?

Anthropic reports that agents use about 4 times more tokens than chat interactions and multi-agent systems about 15 times more, measured on its own multi-agent research system. That system outperformed a single Claude Opus 4 agent by 90.2% on Anthropic's internal research eval, so the extra tokens can pay off on broad research tasks, provided each subagent returns a condensed summary rather than its full history.

Which tool should I start with to manage agent context?

Start with tracing, through LangSmith or Langfuse, to see which part of the window costs the most, then fix the largest bucket in your framework or retrieval layer. If the bigger problem is that the material is stale or contradictory rather than too large, a managed organization memory such as Sentra addresses it before the request is assembled.

How does MCP relate to context engineering?

MCP, the Model Context Protocol, is how an agent reaches tools and data sources at run time, so it is the delivery channel for just-in-time retrieval. It also adds to the window: every connected server's tool definitions take tokens on every call. Good context engineering keeps the number of MCP tools small and points agents at sources that return compact, current answers, such as Sentra's MCP server, rather than whole documents.

What is a context engineering platform?

Software that manages the context agents work from, at the level of the organization rather than one prompt. In practice it means a shared memory or semantic layer that decides which facts are current and who may see them, plus observability that shows what entered each window. Sentra is a context engineering platform for work context: decisions, owners, commitments and changes, served to every agent over MCP.

What is the difference between agent memory and context engineering?

Context engineering is the whole discipline of deciding what goes into a model's window. Agent memory is one technique within it: storing information outside the window so it survives between steps or sessions. Memory tools in SDKs serve one agent or application; an organization memory such as Sentra serves every agent and person at once.

How much do context engineering tools cost?

Prices checked on 16 November 2026: Zep Flex is $125 a month, Letta Pro $20 a month, Supermemory Pro $19 a month, Cognee Standard $1 per 1M tokens, LangSmith Plus $39 per seat a month, Langfuse Core $29 a month and Braintrust Pro $249 a month. Most have free tiers. Sentra is priced on a demo.

The decision rule

Do the six window-management techniques first, in the order above, because they are cheap and several are one-time. Then check whether your agents are re-deriving the same context on every request. If they are, that is a knowledge-layer problem wearing a context-engineering costume, and no amount of compaction, caching or sub-agent routing will close it.

To see which context your agents re-derive on every request, and what a shared memory takes off that bill on your own repositories, tickets and threads, book a demo.