Context is everything actually included in the prompt sent to the LLM at each decision point — the goal, relevant history, available tool definitions, and recent observations. It's the agent's entire "field of view" for that one decision.
What Typically Goes Into an Agent's Context
System instructions:
"You are a data-analysis agent. Use the available tools to
answer the user's question. Only call a tool when necessary."
Available tools (schema):
- run_sql_query(query: string)
- get_table_schema(table_name: string)
Goal: "What was our top-selling product last month?"
Recent history:
- Called get_table_schema("sales") → returned columns: id, product, amount, date
- (agent now deciding its next action based on the above)
All of this — instructions, tool schemas, goal, and history — competes for space in the same bounded context window.
Context Grows With Every Iteration
Each loop iteration typically adds more to the history (the new action and its observation), so context tends to grow as a task progresses. Left unmanaged, a long-running agent task can approach or exceed the context window, degrading decision quality or causing failures. This is why real agent systems often summarize or prune older history rather than keeping everything verbatim forever.
Context Design Is a Real Engineering Decision
| Choice | Tradeoff |
|---|---|
| Include full tool result verbatim | More accurate, but consumes more context budget — problematic for large results |
| Summarize tool results before adding to context | Saves space, but risks losing detail the agent needs later |
| Keep full history | Maximum information, but grows unbounded |
| Keep only recent N steps | Bounded size, but the agent can "forget" earlier relevant findings |
See Context Design for the deeper engineering patterns.
Common Mistakes
- Dumping entire raw tool outputs (e.g. a huge JSON API response) into context unfiltered, wasting context budget and increasing cost per call
- Not monitoring context size as a task runs longer — a task that works fine in short demos can silently degrade once real-world tasks run for many more iterations
Interview Relevance
"An agent's answers get worse the longer a task runs. What would you investigate?" — context growth and window pressure is one of the first, most likely causes to check.
Practice Question
An agent's tool returns a 50,000-word document as a single observation. Propose a way to include it in context without overwhelming the context window.