DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk6 min

How to Select the Right Context for an AI Agent

Context engineering helps AI agents use the right instructions, tools, history, and evidence at each step. Learn which context strategy fits each problem.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Context engineering is the work of deciding what an AI agent can use at each step—not just writing its prompt. It means selecting and maintaining the instructions, tool definitions, conversation history, retrieved evidence, and saved state that enter the model’s active context. The goal is to give the agent enough relevant information to act well without filling its limited working space with material that does not help its next decision.

What is context engineering?

Context engineering is the ongoing design of the information supplied to a model during inference. Anthropic defines it as strategies for curating and maintaining the optimal set of tokens, including information that reaches the model outside the prompt itself. Anthropic’s guide to context engineering frames the task as choosing the context configuration most likely to produce the desired behavior.

As an Amazon Associate I earn from qualifying purchases.

Prompt engineering focuses on instructions and wording. Context engineering includes that work, but also asks what else the agent needs now, what it can fetch later, and what should be summarized or discarded. In a multi-step agent, the answer changes as tool calls return results and the task progresses.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

What counts toward an agent’s context?

The context window is the text a model can reference while generating a response, including the response itself, according to Anthropic’s context-window documentation. The active context may contain:

  • System and developer instructions, plus the current user request and constraints.
  • Tool definitions that tell the model which actions are available and how to call them.
  • Earlier messages, decisions, and assistant-generated output.
  • Tool results, such as file contents, search results, or API responses.
  • Retrieved documents or other external evidence relevant to the current step.
  • Output tokens generated by the model; depending on provider and model, other configured or reasoning tokens may also count toward the limit.

Tool definitions and returned results consume context too. As a result, an agent can run into context pressure even when its visible conversation is short. Exact limits and counting rules vary by provider and model, and change over time; check the target model’s current documentation rather than assuming a capacity applies universally.

Why isn’t a larger context window enough?

A bigger window can accommodate more material, but it does not make every included token useful. Anthropic describes context as a finite resource with diminishing returns, and its documentation warns that accuracy and recall can decline as token counts grow. Irrelevant content competes with task-critical instructions and evidence for the model’s attention.

Position can matter as well as volume: information buried in a long history may be less useful to the next decision than a concise, current statement of the goal and constraints. Context design therefore means managing relevance and organization—not simply maximizing the number of tokens supplied.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

How do I manage context for a long-running agent?

Start by identifying what the agent needs on its next inference step. Keep stable instructions and current constraints available; bring in past decisions, evidence, or detailed tool output when they affect the next action. For long tasks, plan explicitly for state recovery: the agent may need to continue after older messages have been compressed or a session has ended.

Retrieve evidence when it is needed

Use retrieval to bring relevant external material into the active context at the point it can inform a decision. Embedding-based retrieval is one common pre-inference approach. For capable agents, just-in-time strategies can fetch information as the task calls for it, rather than loading an entire corpus at the start.

Retrieval is most useful when the source material is too large or changeable to keep in every request. The application still needs to retrieve the right passages and give the model enough context to interpret them; retrieval does not guarantee relevance or correctness by itself.

Compact history when the conversation is the problem

Compaction summarizes a long conversation so the agent can continue with a shorter history. A useful summary preserves the goal, constraints, decisions already made, unresolved questions, and implementation details needed to proceed. It should not flatten away distinctions that could change the next action.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Clear old tool results when outputs dominate

Tool-result clearing removes old, re-fetchable outputs from active context while retaining the fact that the call occurred. This can help when raw file reads, search results, or API responses have accumulated. Keep a result if it contains information that cannot be recovered or would be costly or risky to fetch again.

Use persistent memory for knowledge that must survive

Memory stores selected information outside the active context so it can persist across context resets or sessions. It is appropriate for durable facts, preferences, or project state that future steps genuinely need—not as a dumping ground for every interaction. In Anthropic’s described memory-tool approach, the application developer controls the storage backend.

Leave structured notes for long-horizon work

For a project that may span many steps or sessions, structured notes can record progress and make state easier to reconstruct after a reset. Focused subagents can also handle bounded subtasks with narrower context. Both approaches depend on good task decomposition and a clear handoff: the main agent needs to know what was done, what remains, and which findings matter.

Which context technique should I try first?

Problem Technique What it changes
Too much external material to load at once Selective retrieval Fetches relevant evidence into context when needed.
Conversation history is growing too long Compaction Replaces older history with a summary of task-critical state.
Large, reproducible tool outputs are accumulating Tool-result clearing Removes old outputs that can be fetched again while preserving that the calls occurred.
Knowledge must persist across context resets or sessions Persistent memory Stores selected information outside the active context for later use.
A long task needs focused parallel work or recovery notes Structured notes or focused subagents Records progress or delegates a bounded task with a deliberate state handoff.

These methods address different sources of context pressure and can be combined. Choose based on what is growing or being lost: history, tool output, external evidence, or state across sessions.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How should I evaluate a context strategy?

Test changes against the agent’s real workload and tool-use pattern. A technique that helps a web-search agent may not help one that repeatedly edits files or queries a database. Compare configurations under the same tasks and look for trade-offs in task performance, token use, latency, and reliability.

  • Identify where context growth comes from: message history, tool definitions, tool results, or retrieved material.
  • Specify what each approach retains, removes, or stores outside the active context.
  • Check whether the task needs persistence across turns, resets, or sessions.
  • Measure whether the agent still uses the right evidence and preserves important decisions after summarization or clearing.
  • Track engineering effort and control over any external storage or retrieval system.

Anthropic’s agent patterns cookbook recommends matching context-management primitives to the workload’s actual problem and testing clearing configurations against its tool-use pattern.

What do Anthropic’s evaluation results show?

In a 2025 announcement, Anthropic reported results from its own internal agentic-search evaluations: combining its memory tool with context editing improved performance 39% over its baseline, while context editing alone improved it 29%. In a separate 100-turn web-search evaluation, Anthropic reported an 84% reduction in token consumption using context editing. These are vendor-reported results for Anthropic’s evaluations, not universal guarantees or independent replications; they do not establish that the same technique or gains will transfer to another agent or workload. Anthropic’s context-management announcement

A practical starting decision

  • If irrelevant documents are entering every request, begin with selective retrieval.
  • If old conversation turns are the main source of growth, test compaction and validate that its summaries preserve decisions and open issues.
  • If repeatable tool responses dominate, test clearing those results and retain anything that cannot safely be fetched again.
  • If work must continue across sessions, define what belongs in persistent memory or structured progress notes.
  • If a subtask can be isolated, delegate it only when the task boundary and return handoff are clear.

Make one targeted change at a time, then compare it on representative tasks. The best context is not the largest one: it is the smallest, clearest working set that gives the agent what it needs for the next decision.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.