Preface: What an Agent Forgets
The Context Engineer — The Pramana Framework, Companion 7
By the end of Companion 6, ShopBot had a nervous system.
Sahadeva had built the MCP layer — the contracts that let the agent reach the inventory service, the order management system, the CRM — without Arjun hardcoding a single function schema. The agent could ask for a stock level without knowing that behind the get_inventory tool was a PostgreSQL database and a FastAPI service managed by a team in Pune. The contract was the only thing the agent needed to read. The implementation was someone else's problem.
The MCP layer held. The contracts worked. The architecture was, for the first time, genuinely composable.
What Companion 6 did not ask was: what does the agent do with what it receives?
A tool call returns data. Sometimes a small amount — a stock count, a status code, a confirmation ID. Sometimes not. The order history endpoint returns the full record for every order placed by the customer in the last ninety days. The product detail tool returns the complete structured object — every variant, every dimension, every supplier note, every image URL. The inventory reconciliation endpoint, when Arjun first called it during the Diwali sale, returned forty-two thousand tokens of structured JSON.
The context window holds eight thousand.
The agent does not refuse. It does not raise an error. It takes what it can fit. It discards the rest silently, in whatever order the truncation logic happens to prefer — usually the end, usually the part that would have mattered. Then it reasons from what remains.
This is not a retrieval failure. The Grounding Layer worked. The MCP server responded correctly. The data was accurate. The failure happened afterward, in the space between what the tool returned and what the agent actually carried forward. The agent had the information. The architecture had no mechanism for deciding which part of it was worth keeping.
Context management is the failure mode nobody talks about because it does not announce itself the way retrieval failures do.
A retrieval failure has a symptom: the agent says something wrong, or says it does not know. You can measure it. RAGAS scores it. The grounding gap is visible. You fix the retriever, improve the embedding model, adjust the threshold, and the score moves.
A context failure looks like correct behavior. The agent answers. The answer is grounded — in what it carried. The problem is that what it carried was not the right selection from what was available. The inventory count was from the first tool call, not the third. The customer's complaint was in the part of the conversation that got compressed out. The instruction about handling returns only applies to zUdyog's terms, not Vastralaya's — but both versions were in context, and the agent used the older one because it appeared first.
There is no metric on the dashboard that says: the agent used the wrong slice of context. There is only a support ticket, two days later, from a customer whose return request was processed under the wrong policy.
Arjun encountered this problem not as a single failure but as a pattern he could not initially name.
ShopBot was performing well by every score he tracked. Faithfulness was 0.88. Tool call accuracy was at 0.91 across the C6 test suite. The MCP layer had not produced a single schema violation in three weeks of production traffic. Sahadeva had not flagged anything. Krishna had not written anything on the whiteboard.
But there was a class of failure that showed up only in longer sessions — conversations with four or more tool calls, flows where the agent had to carry state across several steps, multi-product queries where the initial retrieval returned more than the context window could accommodate cleanly. In these sessions, something would go wrong in a way that was hard to trace. Not a hallucination. Not a tool failure. Something quieter: a decision made from an incomplete picture, an answer that was technically grounded but grounded in the wrong part of what the agent had seen.
It took Arjun a week of reading traces to see it clearly. The agent was not forgetting. It was carrying the wrong things.
This book is about what agents carry.
Not what they retrieve — that is the Grounding Layer, and four books and two companions have covered it. Not what they call — that is the MCP layer, and Companion 6 covered it. What they carry between calls. What survives the move from one step in a multi-step flow to the next. What gets compressed, what gets dropped, what gets preserved exactly, and what gets reconstructed from a summary that may have missed the one line that mattered.
The chapters that follow build a complete context management architecture: counting tokens before calling, chunking for agent context rather than retrieval, summarizing without losing what cannot be lost, isolating context between agents that should not share memory, choosing between MCP tools and RAG retrieval and private in-memory state based on what the agent actually needs to know, and caching shared context in Redis for the case where multiple agent instances need to stay coherent under load.
By Chapter 9, ShopBot's context will be managed — not by default truncation and whatever the LLM decides to attend to, but by explicit rules about what enters the window, how large each component is allowed to grow, what gets compressed and when, and what must survive compression intact.
There is a Pramana that knows what it needs to carry and what it does not — that does not arrive at each step burdened by the full weight of every step before it, but carrying only the truth that the next judgment requires.
The agent that carries everything is not better than the agent that carries the right things. It is slower, more expensive, and less reliable — because reasoning over a context window bloated with irrelevant data is not the same as reasoning over a window that contains exactly what the next decision needs. The Grounding Layer makes knowledge honest. Context management makes honest knowledge usable.
This book is not about what the agent knows. It is about what the agent carries — and why those are not the same thing.