Context engineering is deciding what goes into a model's limited window on each turn: which instructions, files, tool results and memories, and in what form. With too little the model lacks what it needs; with too much it loses the thread and costs more. Long tasks depend on what is kept, fetched and trimmed.
An analogy
A small desk in a large library. Only what lies on the desk can be read, so a librarian keeps choosing: bring this book, clear that pile, write a summary card before the stack tips over. The reader's work is exactly as good as what is on the desk at that moment.
Context engineering is deciding what goes into the model's window each turn (instructions, tools, retrieved facts, history) and what stays outside. These talks describe the same pressures: windows rot as they fill, tool definitions and tool results are the fastest way to fill them, and long runs force compaction or external logs. The answers are on-demand loading, sub-agent isolation, small durable memory, a stable cacheable prefix, and evals to prove the changes work.
Context windows and context rot
A bigger window does not mean a better desk. Speakers describe accuracy and instruction-following dropping as the window fills, with the middle of a long input hardest to use, so deciding what stays out matters as much as what goes in. How bad it gets depends on the model, and one speaker shows the instruction ceiling moved about 10x in a year.
The limit gate checks every incoming item against the room left in the window and sends back what does not fit.
The desk slots take in the assembled prompt and each new result, and hold all of it in one window of fixed size.
The fill gauge counts the tokens on the desk and reports the level to the compaction trigger.
The reader (the model) attends to every token on the desk and writes the next action; the more tokens, the less attention each one gets.
~350K tokens
Where Bergum puts the usable context for current models before quality degrades (his opinion), compared to a 1.4 MB floppy disk Jo Kristian Bergum
30-50%
Accuracy drop on long inputs well before the window limit, across 18 models, in Chroma's context-rot work as relayed by Voss Laurie Voss
200-300 -> ~2,000-5,000 instructions
Rules a frontier model can follow at once before accuracy collapses, a year ago vs. in Voss's rerun of IFScale (reported) Laurie Voss
A log-monitoring agent keeps pulling large tool outputs into context; as the window grows, the model hallucinates and its reasoning degrades, and it forgets the middle of long inputs. Elizabeth Fuentes Leone
The more tokens in the window, the less attention each gets, and the attention matrix grows quadratically with length, so Martinez advises keeping the window as small as possible. Ignacio Martinez
Martinez says studies show a problem is solved more accurately at zero tokens than at 256K tokens, and past the advertised limit (256K or 1M) performance falls off sharply. Nacho Martinez
When it breaksGPT-5.5's polite half-finished report. In Voss's instruction-overload test, GPT-5.5 began a long business report, then partway through said the task was silly and stopped, leaving most required words missing. It looks like a real answer unless you read to the end. Laurie Voss
Open questionShould you keep the context window as small as possible, or has the instruction-following ceiling moved enough to fill it?
Keep the window as small as possible, because attention per token falls as you add more Ignacio Martinez
Skills and prompt files can now be very long; fitting everything in is no longer the hard problem, cost and verification are Laurie Voss
On DeepSeek, keeping the full history recalled exact details 95% of the time, while summarizing or compacting first recalled them 32% of the time Samridhi Vaid
Compaction, summaries and session logs
When history will not fit, harnesses summarize, truncate or compact it. Speakers split on whether generic summaries can be trusted, and several converge on the same design: keep the full append-only log outside the window and treat any summary as one lossy view that can be rebuilt differently.
The session log keeps every event in an append-only record, so nothing is thrown away for good.
The compaction trigger watches the fill level and, past a threshold, sends the history to be summarized; below it, the turn goes on.
The summarizer, a general model or one trained for it, writes a summary or checkpoint that replaces the older turns.
The summary check compares the summary with the log and refuses one that dropped what the task still needs.
The window builder builds the next window from the log by a pluggable strategy: the last N events, a summary, or a mix.
The log query lets the agent look up the stored log when the summary turns out to be missing something.
7 and 12 hours
Codex runs OpenAI's team cites as spanning many compactions in one thread Gabriel Chua
700 per day
Deploys to Lovable's agent runtime; it works because the process is stateless and each turn is persisted to the task history (reported) Fabian Hedin
95% vs. 32%
Exact-detail recall on DeepSeek with full history vs. after summarizing or compacting, in the Towards AI tutor tests (reported) Samridhi Vaid
97%
Share of tokens served from cache in a full-history, 36-turn DeepSeek run, which made it the cheapest setup (reported) Samridhi Vaid
13.3% -> 38.3%
GPT-5.6 Sol's score on the ARC-AGI-3 public set with the official harness vs. with retained reasoning and compaction (OpenAI reports about 3x the score with 6x fewer output tokens) OpenAI
Strands offers sliding-window, summarizing and hybrid conversation managers; the summarizing one keeps the last few messages (four in the demo) and summarizes the rest. Elizabeth Fuentes Leone
Fuentes lists naive summarization as an antipattern, because the summary may lack what the agent needs to answer. Elizabeth Fuentes Leone
Anthropic's managed agents keep an append-only event log so nothing is thrown away, and a flexible compaction strategy decides which events (all, last N, or a summary) enter context. Priyanka Phatak
When it breaksTool output overload forces compaction and rework. At LinkedIn, as agents used more tools every tool output filled the window until the agent compacted mid-task, lost information, and had to redo work. Ajay Prakash
Open questionCan you trust LLM-written summaries to carry a long task?
Naive summarization can drop the very facts the agent needs later, so treat it as an antipattern Elizabeth Fuentes Leone
Compaction the model was trained for works: Codex threads span many compactions and users report it rarely forgets Gabriel Chua
Do not compact if the cache is on: keeping everything was cheaper, faster and better at recall in their tests Omar Solano
Tool lists and tool output bloat
Tool definitions and tool results are the fastest way to fill a window. Speakers show three fixes: load tool definitions on demand, keep big results outside the window (files, pointers, code that returns only the answer), and cap loops. They disagree on whether to keep tools or give the model a sandbox.
The tool index shows the agent a search step instead of every tool; a tool's schema loads only when the agent picks it.
The call cap counts calls to each tool and refuses the call past the limit with a plain reply.
The tool runner runs the call, in code or a shell where it can, so intermediate results never reach the window.
The blob scan keeps binary blobs, base64 images and secrets out of a result and has a reference returned instead.
The result trimmer cuts a large result to its head and tail plus a pointer ID, and sends the middle to storage.
The pointer store holds the stored middle; the agent fetches it back by ID only when it needs it.
43% fewer tokens, 31% lower cost
Arize reports after moving its agent to code mode, with latency about constant Mikyo King
~1/3 of context
Share a naive MCP client could burn on ~100 registered tools before any work, per Curn Jan Curn
30-40 tools
LinkedIn's stated limit before MCP degrades performance; they front thousands of tools with 3 meta tools Ajay Prakash
Curn says naive MCP clients register every tool up front, so ten servers meant about a hundred tools and roughly a third of context gone before the first question; he calls it a harness problem, not a protocol problem. Jan Curn
Progressive tool discovery, introduced by Anthropic then Cursor, loads only the one or two tools needed instead of all of them; Cloudflare's code mode treats MCP tools as code. Jan Curn
King's code mode gives the agent tool search plus a programming environment: it calls many tools in one turn and puts only what it needs back into context. Mikyo King
When it breaksBase64 images blew up the window. Figma's first MCP output embedded base64 image data in the code it returned, which exploded the context window. Jesse Lumarie
Open questionShould an agent get a catalog of tools or a sandbox and code?
Give it a sandbox: search for tools, then compose them in code and return only what is needed Mikyo King
Keep tools, but hide them behind three meta tools (search, get schema, execute) so the catalog scales to thousands Ajay Prakash
Retrieval, agentic search and knowledge layers
Agents start each task knowing nothing about a company, so something must fetch the right facts. Speakers argue over lexical vs. semantic vs. hybrid retrieval, and over whether to build a persistent company-wide context layer. The shared warning is that finding a document is not the same as understanding.
The source router sends a question to a live API call, a synced cache or a derived summary.
The search tool (BM25, grep, a filesystem workspace) runs the agent's query, and the agent can search again after each read.
The snippet list returns titles and snippets first, and the agent opens only the ones it wants.
The zero-result check treats a search that returns nothing as a possible failure and sends the agent back to search.
The conflict check lets a newer, fresher source override an older hit, so the first plausible answer does not win.
The answer composer returns a compact, sourced answer instead of raw documents.
21M -> 10.8M tokens
Tokens for the same task without vs. with Unblocked's context engine (reported by Waselnuk) Brandon Waselnuk
150,000 -> under 1,000 tokens
Prompt tokens to describe tooling to agents, before vs. after Pinecone's Nexus (reported) Edo Liberty
77% faster
Reported speedup from Nexus in early-access customer tests, with better accuracy Edo Liberty
45,000 -> ~5,000 tokens
Context sent per coding query vs. tokens that actually mattered in Sakthivel's measurement (reported) Rajkumar Sakthivel
94%
Reduction in tokens (worst-case baseline of full files) from a local code index; he says real savings are lower Rajkumar Sakthivel
Bergum argues an agentic-search workspace organized as a filesystem gives progressive disclosure: show title and snippet, then let the model read more with grep, sed and similar tools. Jo Kristian Bergum
Bergum says BM25 suits agent users: they write long precise queries, exact matching on names and SKUs matters, it is cheap, and the model can see why a query matched. Jo Kristian Bergum
Waselnuk warns that MCP access is not understanding: the agent may never call the tool, or stops at the first plausible answer (satisfaction of search) and misses a newer Slack decision. Brandon Waselnuk
When it breaksSatisfaction of search. Agents using MCP or a wiki stop at the first plausible source, such as an architecture record, and never see last night's Slack thread that says to do the opposite. Brandon Waselnuk
Open questionIs lexical search enough for agents, or do you need semantic/hybrid retrieval?
BM25 plus grep is a strong agent primitive: exact matches, cheap, and easy for the model to inspect Jo Kristian Bergum
Similarity alone is not enough; combine vector, keyword, relational, graph, temporal and feedback signals Anders Swanson
Run dense and BM25 together: dense alone lost buried facts at 400K tokens while BM25 found them Samridhi Vaid
Memory systems across sessions
A window is not memory: when a session ends everything on the desk is lost. Speakers compare tiny files, vector stores, graph stores and full databases for what carries over, and stress that memory needs scoping, review and feedback or it fills with stale, conflicting or poisoned entries.
The memory writer runs after the session as a background job and keeps preferences, facts and procedures, not raw transcripts.
The memory screen refuses poisoned or conflicting entries before they are stored.
The memory store keeps the notes: one capped markdown file per user, or typed episodic, semantic and procedural records.
The vault file holds what a fresh window must read first: a feature list and a progress file, in JSON.
The staleness sweep retires or merges notes that a lifecycle event or recall feedback marks as out of date.
The memory loader puts the notes in the next session's prompt, or retrieves them by hybrid search.
8,000 characters
Cap on Arize Alyx's one-markdown-file-per-user long-term memory, which beat knowledge graphs for them Fuad Ali
1,000 vs. 50,000+ records
Swanson: a memory system can work well at a thousand records and drift into weird results at fifty thousand or a million Anders Swanson
Arize tried vector retrieval, episodic and semantic stores and temporal knowledge graphs, and landed on one markdown file per user capped at 8,000 characters. Fuad Ali
Arize's memory file is loaded on every full request and is written by a background job after the session, which makes it small, exact and easy for a human to audit. Fuad Ali
Swanson says files, wikis and grep give no governed recall and do not scale in multi-tenant settings; he argues a memory layer built on files ends up as a homemade database. Anders Swanson
When it breaksStale memories after a toolchain change. If a project used npm and then switched build systems, memories about npm are still recalled by agents later and mislead them. Anders Swanson
Open questionShould agent memory live in files or in a database?
A single capped markdown file per user beat vector retrieval, episodic stores and temporal knowledge graphs Fuad Ali
Files and grep do not scale or give governed recall; carried far enough you end up building your own database Anders Swanson
Instruction files, skills and progressive disclosure
Always-on rules cost tokens on every turn, so speakers push toward short descriptions that open into full playbooks only when needed. They also say that rules written for older models can now hurt, and disagree on whether skills should be hand-written, distributed through MCP, or replaced by a managed knowledge layer.
Rule files (the system prompt, CLAUDE.md) are pinned to the desk and cost tokens on every turn.
The rule audit runs when the model changes and deletes the rules the new model no longer needs.
The skill index keeps only each skill's name and description in the system prompt; the full text stays on the shelf.
The skill loader reads a skill's full text when the agent picks it and returns it as a tool result.
The skill distiller writes a new skill from the trace of a successful or failed run.
The skill scan screens each new skill before it is shared and sends back ones with hidden code or injections.
36% -> 100%
Success rate on a task (Chromium fork on AWS Lambda, Sonnet 4.6) after a distilled skill was reused (reported, no sample size) Rafal Wilinski
51%
Cut in instruction tokens when an optimizer replaced long worked examples with compact rules (Pane's worked example) Alvin Pane
Wilinski defines a skill as a playbook: the harness sees only a short description, then reads and injects the full text when relevant, which can steer a long run away from a wrong trajectory. Rafal Wilinski
LinkedIn returns a playbook's instructions as the tool output when the agent invokes it, so one MCP carries both tools and instructions on how to use them. Ajay Prakash
LinkedIn asks that each playbook be self-contained and about one task, and big playbooks be split into smaller referenced ones, which allows reuse and progressive discovery. Ajay Prakash
When it breaksOld prompt rituals backfire. Instructions telling the model how to think and verify, plus contradictory rules, were harmless or ignored by weaker models, but frontier models spend extra tokens on them and get confused by contradictions. Lance Martin
Open questionHow should company skills reach agents: a governed MCP server or a managed knowledge layer?
A remote MCP server as the source of truth that searches and serves the right version of each skill Rafal Wilinski
Stop hand-writing skills and plugins; tell the knowledge layer what you care about in a manifest and let it organize itself Edo Liberty
Sub-agents and context isolation
A sub-agent gets its own window, does the heavy reading, and returns a short result so the main desk stays clean. Speakers agree on the benefit but disagree on cost and complexity: you still pay for the tokens, handoffs lose detail, and Lovable and Arize both rolled back specialist-agent designs.
The brief hands a heavy subtask (a big file, a trace, a wide search) from the main agent to a sub-agent.
The pointer share passes an ID to stored data between agents, so each fetches what it needs instead of a whole context.
The clerk's window holds the large input and does the heavy reading; none of it enters the main window.
The evaluator, in a separate window with its own prompt, checks the clerk's work and sends back what fails.
The result slot returns only the distilled answer, or a pointer to stored data, to the main desk.
2.6% -> 45.4%
Reported accuracy jump of recursive language models on a long chain-of-thought benchmark (third-party test, relayed by Madura) Kevin Madura
10 -> 1
Arize collapsed ten specialist agents into one agent with on-demand skills Fuad Ali
Fuentes says sharing a whole context between agents adds garbage because not every agent needs it, so agents in a swarm pass a memory-pointer ID through invocation state. Elizabeth Fuentes Leone
Curn says sub-agents keep the main window clean but you still pay for the tokens, and a sensitive tool result stays in context and can be abused. Jan Curn
Madura says an RLM keeps the full input as a REPL variable, delegates subtasks to sub-models, and gets back only what matters, so the window fills more slowly. Kevin Madura
When it breaksLovable's multi-agent framework made the product worse. Lovable built a main agent that spawned specialist implementation, front-end and back-end agents that messaged each other. It made the product worse, so they went back to one main model plus small retrieval models. Fabian Hedin
Open questionSplit work across sub-agents or keep one agent with on-demand skills?
Isolate heavy work in sub-agents or sub-models and share only pointers or results Elizabeth Fuentes Leone
Sub-agents still burn tokens and keep sensitive values in context, so they only push the problem further Jan Curn
One agent loading skills and tools on demand worked better than ten specialists Fuad Ali
Give data-heavy work to sub-agents; the main agent stays small Sally-Ann DeLucia
Agents resend the same prefix every turn, so cache hits decide the bill. Speakers say input tokens, cache-hit share and turn count drive agent cost, that a single changed byte early in the prompt wipes the cache, and that caching is the first of several levers before shrinking prompts or downsizing the model.
The prompt orderer lays the prompt out from stable to volatile: system and tools, then rules and memory, then session state, then messages.
The prefix check compares the start of the prompt with last turn's, byte for byte; one changed byte there is a cache miss.
The hit-rate meter counts cached and uncached input tokens for every turn.
Server-side state keeps the session under an interaction ID, so history is not rebuilt by hand and the prefix stays intact.
The cost ledger turns input tokens, cache-hit share and turns per task into the bill for the task.
$21 -> over $200
Cost of one knowledge-work agent task with vs. without prompt caching, on Artificial Analysis' benchmark George Cameron
up to 72%
Cost reduction Anthropic's team found on internal benchmarks by fixing prompt-cache use in default harnesses Lance Martin
~1/10 price
Rate at which Martin says cached prompt tokens are billed relative to base input tokens Lance Martin
90% input / 10% output
Sakthivel's split of AI coding cost, which is why he cuts input first (reported) Rajkumar Sakthivel
56% to 87%
Cost reduction TokenPilot reports against prior context managers on two agent benchmarks, from stabilizing prefixes and evicting in batches Hugging Face
Martin says prompt cache is billed at about a tenth of base tokens and is faster, but it is a strict prefix match, so even a one-byte change in the prefix invalidates it. Lance Martin
Martin orders prompts as system instructions and tools (global), CLAUDE.md and memory (per project), session state, then messages; a cache diagnostic found up to 72% savings in internal benchmarks. Lance Martin
Cameron says today's agent-cost drivers are input tokens, cache-hit share and turns per task; with zero cache hits a $21 task costs over $200. George Cameron
When it breaksOne stray space wiped the cache. Ivan Leo says some startups lost their cache from a single whitespace they mistakenly added while managing opaque thought signatures by hand. Ivan Leo
Open questionIs a big instruction prefix a cost problem or a solved one?
A prompt with thousands of instructions is expensive and slow, so adding more is a cost-latency trade-off Laurie Voss
The repeated prefix is billed at about a tenth the rate if you keep it stable, so protect the cache Lance Martin
Cache first, then shrink the instructions (one example cut instruction tokens 51%), then downsize the model Alvin Pane
Keep the full history cached: it was the cheapest setup at 97% cached tokens, cheaper than summarizing each turn Samridhi Vaid
Measuring context quality
Context choices only count if you can see their effect. Speakers say the hard problem moved from fitting rules in to verifying that the model followed them, and they describe tests that replay long runs, compare candidate prompts with confidence intervals, and warn that optimizers overfit easily.
The task set holds production-like cases, including long sessions replayed ten turns deep.
The repeat runner runs the candidate and the current prompt on the set several times, in a sandbox.
The verifier scores each run pass or fail, and sends a failing run to the failure press.
The variance scale subtracts normal run-to-run disagreement from the gap between the candidate and the current prompt.
The ship gate lets a change through only if the confidence lower bound is above zero in the critical categories; otherwise it sends the candidate back to run again.
The failure press turns failing runs into new rules, memory-ranking signals and skills, and queues them as the next candidate.
443 vs. 2,463
Regressions vs. improvements in Pane's illustrative shadow test of a prompt half the size (his worked example) Alvin Pane
$29
What Voss says his 2,300 test calls across seven models cost, showing context research can be cheap Laurie Voss
~$600
What Towards AI says its compaction evals cost to run (reported) Samridhi Vaid
Voss says the old hard part was fitting instructions in; now it is verifying the model followed them, and the answer is checking the output with an eval each time. Laurie Voss
Voss cites a 46-model paper: a model can ace a benchmark yet rewording or reordering the same instructions can swing how well it follows them. Laurie Voss
Arize runs agents through Harbor in sandboxes with 1/0 verifiers across permutations and tracks pass@k, because the same task can flake. Mikyo King
When it breaksAn impossible eval burns tokens. Martin says that with a poorly specified eval where the last 20% is unsolvable, the hill-climbing agent burns huge numbers of tokens chasing it. Lance Martin
Open questionCan you let an optimizer or the model rewrite your prompts?
Yes: an optimizer cut instruction tokens 51%, then paired shadow tests with confidence intervals checked quality held Alvin Pane
Carefully: prompts are very easy to overfit, since the model wiggles them into shapes that win the eval but do not match production Lance Martin