Long-running AI agents do not need to remember everything. They need to know what matters next. That is the practical engineering lesson from NVIDIA’s November 2026 preprint, You Don’t Need Long Context. The research challenges a common design instinct: keep appending every tool call, file excerpt, test result and decision to the model’s conversation until the task is finished.
That approach is convenient, but it turns working memory into an ever-growing transcript. Every new model call must process more history, including details that may no longer affect the next decision.
This guide turns the paper into an implementation playbook for engineering teams building coding agents, research agents and multi-step automation. You will leave with a context architecture, a reusable handoff template, pseudocode, evaluation metrics and a rollout plan.
The core idea: separate working memory from durable memory
Think of an agent like an engineer joining a project halfway through. They do not need every Slack message, terminal command and meeting transcript read aloud. They need a clear brief: the objective, what is known, what has changed, what remains, where the evidence lives and what to do next.
Build agents the same way. Keep the active context small and decision-ready. Keep the full history, source documents, logs and artifacts outside the prompt, where they can be retrieved when needed.
- Working memory: the compact state required for the next decision or action.
- Durable memory: original files, tool outputs, logs, diffs, test reports and decision records.
- Task contract: the original goal, constraints and acceptance criteria. Preserve this across every reset.
The key distinction is that compacting the prompt must not mean deleting the evidence. You are changing what is loaded, not what exists.
What the NVIDIA paper actually found
The paper, by Peter Belcak and colleagues at NVIDIA, evaluates ways to keep an agent’s active context short across long-running tasks and large-input tasks. It compares full-history accumulation with two compaction strategies:
- End-of-Conversation Compaction (EoCC): when the conversation reaches a threshold, the agent writes a bounded handoff brief and continues in a fresh conversation with the original task and that state.
- Single-Action Compaction (SAC): the agent performs one environment action, observes the result, updates its state, and starts a fresh context for the next action.
For long documents, the researchers also tested selective reading: leave source material in files, search it, and bring only relevant excerpts into the active context.
In the paper’s serving experiments, configuring a 16K rather than 256K context window produced 3.6×, 5.6× and 7× more output tokens per second for GLM 5.2, Kimi K2.6 and Qwen 3 Coder Next respectively on the authors’ H100 setup. This is a throughput result, not a claim that every task completes 7× faster or that every API bill falls by the same factor.
Across the long-horizon benchmark configurations, compaction often stayed close to the full-history baseline, although some settings improved and others lost accuracy. In the single-action experiments, performance did not collapse, but there were measurable drops on some model-task pairs. The result is encouraging, not universal proof.
Engineering takeaway: stop treating the context window as the agent’s database. Treat it as a limited workspace populated from a durable, searchable record.
1. Design the agent’s memory architecture
Before changing prompts, decide where each kind of information belongs. A practical starting architecture looks like this:
- Immutable task contract: objective, scope, constraints, acceptance criteria and safety rules.
- Mutable task state: current status, decisions, findings, blockers and next action.
- Artifact store: repository files, diffs, test output, logs, generated documents and screenshots.
- Retrieval layer: grep/ripgrep, code search, database queries, vector search or targeted file reads.
- Audit trail: append-only record of actions, tool results and state transitions.
Do not put everything into a vector database by default. For a code repository, ordinary file paths, symbol search and ripgrep are often faster and more precise. Use semantic retrieval when lexical search is insufficient, and always retain a route back to the original source.
2. Use a forward-looking handoff, not a narrative summary
A weak compaction prompt asks: “Summarise everything that happened.” That tends to preserve chronology and interesting details. A useful handoff asks: “What must the next agent know to take the next correct step?”
Use this template as the state passed between agent sessions:
# TASK STATE
## Objective
[Original goal, unchanged]
## Constraints and acceptance criteria
[Non-negotiable requirements and definition of done]
## Current status
[What is complete; what remains]
## Verified facts
[Facts established by tools or source evidence, with file paths/links]
## Decisions and rationale
[Decisions that constrain future work]
## Changes made
[Files, records, services or resources changed]
## Failed approaches / known risks
[What was tried, what failed, and what must not be repeated]
## Open questions
[Unknowns that could change the plan]
## Next action
[One concrete action, with expected output]
## Evidence pointers
[Paths, IDs, URLs, log locations and test reports]
Keep it concise. Prefer a few precise facts and pointers over a long retelling. If a fact is uncertain, label it as uncertain. Never convert an assumption into a verified fact during compaction.
3. Implement threshold-based compaction first
Start with end-of-conversation compaction. It is easier to integrate into an existing agent loop than resetting after every tool call.
- Choose a context budget that leaves room for the next tool result and response. Do not blindly copy the paper’s 16K setting; tokenisation, model behaviour and task complexity differ.
- Track approximate input tokens for the active conversation, including tool outputs.
- When the compaction threshold is reached, ask the model to produce the structured handoff above.
- Validate the handoff: objective and acceptance criteria must remain intact; file paths and IDs must be valid; completed work must be distinguishable from planned work.
- Persist the handoff and start a fresh conversation with the original task contract plus the compacted state.
- Give the new session retrieval tools for the original logs and artifacts.
Set the trigger below the hard context limit. Leave a safety margin for unusually large tool responses, retries and the next action. Begin conservatively, measure, then tighten.
async function runAgent(task, tools) {
let state = initialState(task);
while (!state.done) {
const result = await modelStep({
system: task.instructions,
taskContract: task.contract,
state,
tools
});
await persistAction(result.action, result.observation);
state = updateState(state, result);
if (await activeContextTokens() >= COMPACTION_THRESHOLD) {
const candidate = await compactToHandoff({
taskContract: task.contract,
currentState: state,
evidenceIndex: await getEvidencePointers()
});
validateHandoff(candidate, task.contract);
await persistState(candidate);
state = candidate;
await startFreshContext();
}
}
return state.finalResult;
}
This is illustrative pseudocode, not a drop-in SDK implementation. Your orchestration framework will determine how token counts, tool calls, persistence and session resets are implemented.
4. Make large inputs searchable instead of prompt-sized
For document-heavy tasks, do not load an entire repository, policy library or collection of PDFs into every model call. Give the agent a searchable source layer and enforce a read workflow:
- Inventory the available sources and record stable paths or IDs.
- Search for terms, symbols, dates, entities and concepts relevant to the current question.
- Read the smallest useful excerpt, with surrounding context.
- Record the source pointer and the finding in task state.
- Retrieve additional passages when evidence conflicts or the answer requires synthesis.
- Verify important claims against the original source before producing the final output.
For software engineering, this means searching for a function or symbol before opening multiple files. For incident response, it means querying logs around the relevant time window. For regulatory analysis, it means retrieving the relevant article, recital or control text rather than loading an entire regulation into every turn.
Important: retrieval is not a licence to ignore context. A relevant passage may depend on definitions, exceptions or surrounding sections. Follow references and retrieve adjacent material when needed.
5. Preserve exact information that must never be summarised away
Some information is too important to leave to a lossy language-model summary. Keep it in structured fields or immutable artifacts:
- Acceptance criteria, contractual requirements and explicit user instructions.
- Exact identifiers, file paths, URLs, commit hashes and database keys.
- Test results, error messages and numerical measurements.
- Security constraints, permissions, approval requirements and destructive-action boundaries.
- Evidence that supports a conclusion, including source locations.
Use summaries to describe the state of work; use source artifacts to establish the facts. For high-stakes or exact-information tasks, retrieve and quote the original record rather than relying on a paraphrase.
6. Consider single-action compaction for tool-heavy agents
Once threshold-based compaction is reliable, experiment with the stricter pattern:
- Read the task contract and current state.
- Choose one bounded environment action.
- Execute it and capture the result.
- Update the state and evidence pointers.
- Start a fresh context for the next action.
This can make each decision easier to inspect and replay. It also introduces overhead: more model calls, more handoffs and more opportunities for state corruption. Use it where actions are naturally discrete, tool outputs are large, or auditability matters. Do not adopt it everywhere just because it is the most aggressive design in the paper.
7. Evaluate quality, not just token count
A smaller context is not automatically a better agent. Run a controlled comparison against your current full-history baseline. Use representative tasks from your own codebase and workflows, not just toy prompts.
| Measure | What it tells you |
|---|---|
| Task success / acceptance rate | Does the agent still finish correctly? |
| Regression and test pass rate | Does compaction preserve engineering quality? |
| Evidence accuracy | Can claims be traced to the right source? |
| Input and output tokens | How much context and generation are consumed? |
| Latency per completed task | Does the workflow actually get faster? |
| Cost per successful task | Does the full system become cheaper, including retries and extra calls? |
| Recovery rate | Can the agent recover when a handoff omits something important? |
Compare at least three variants: full-history accumulation, threshold compaction and selective retrieval. Add single-action compaction only if the workload justifies it. Run multiple trials where model output is nondeterministic, report variance, and inspect failures rather than relying only on averages.
8. A practical two-week rollout
Days 1–2: establish a baseline
- Select 10–20 representative tasks, including long tasks and tasks requiring exact evidence.
- Record current success rate, context growth, latency, retries and cost per successful task.
- Save transcripts and artifacts so failures can be reproduced.
Days 3–4: introduce durable state
- Implement the task-state schema and artifact index.
- Separate immutable task requirements from mutable progress.
- Make logs and tool outputs retrievable by stable IDs.
Days 5–7: add threshold compaction
- Introduce a conservative threshold and structured handoff prompt.
- Validate every handoff before resetting the session.
- Run the benchmark set and inspect every regression.
Days 8–10: add selective retrieval
- Replace bulk file injection with search and bounded reads.
- Require source pointers for important findings.
- Test whether the agent can find facts that are not in the initial working set.
Days 11–14: tune and decide
- Compare quality, latency and cost per successful task against baseline.
- Test edge cases: long tool output, contradictory evidence, failed commands and missing files.
- Roll out only to task classes where quality remains acceptable and operational benefits are real.
Common failure modes (and how to avoid them)
- Over-compression: the next agent loses a crucial constraint. Keep task contracts immutable and validate required fields.
- Narrative summaries: the handoff describes what happened but not what to do. Require a concrete next action and evidence pointers.
- Orphaned evidence: a summary references a file or log that has disappeared. Use stable IDs and test retrieval after every reset.
- False certainty: assumptions become facts. Label verified, inferred and unknown information separately.
- Hidden cost transfer: shorter contexts trigger more calls or expensive retrieval. Measure end-to-end cost per successful task.
- Model-specific tuning: a threshold that works for one model fails on another. Evaluate each model and task class independently.
- Unsafe autonomy: compaction drops an approval boundary or permission constraint. Keep safety rules outside the lossy state and re-inject them every session.
Copy-and-use compaction prompt
You are preparing a handoff for a fresh agent session.
Do not write a chronological summary. Produce the smallest reliable
working state needed to continue the original task correctly.
Preserve:
- the original objective and all acceptance criteria
- hard constraints, safety rules and approval boundaries
- verified facts, with source pointers
- decisions that constrain future work
- completed changes and their exact locations
- failed approaches that should not be repeated
- unresolved questions and material risks
- one concrete next action
Do not invent facts. Mark uncertain information as uncertain.
Do not discard exact identifiers, numbers, paths or evidence references.
The original source files and action log remain available for retrieval.
Return the state using the TASK STATE schema.
The engineering principle
The breakthrough is not a clever summarisation prompt. It is an architectural decision: make the agent’s working memory small, explicit and replaceable, while keeping its evidence complete and retrievable.
That changes how we build agents. We stop asking a model to carry the entire past into every decision and start designing a reliable state machine around it. The context window becomes a workspace, not a warehouse.
Further reading
- Belcak et al., “You don’t need long context” (NVIDIA, arXiv:2611.05306, submitted 3 November 2026) — original research preprint.
- Readable paper overview and benchmark discussion.
Research note: this article interprets a preprint, not a peer-reviewed consensus. Results depend on the models, benchmarks, agent harnesses and serving setup evaluated. Treat the proposed patterns as hypotheses to test against your own workloads.