Imagine building an AI coding agent that spends 30 minutes investigating a bug.

It reads multiple files, executes commands, encounters errors, tries different fixes, and eventually discovers the root cause.

By the time it is ready to implement the solution, its conversation history contains thousands of tokens.

Now imagine deleting that entire conversation and asking the agent to continue.

Sounds like a terrible idea, right?

After all, the agent would lose everything it learned during the investigation.

NVIDIA researchers tested exactly this idea. They built a coding agent that started a fresh conversation after every action, carrying forward only a short written record of its progress.

The surprising result?

With Claude Opus 4.5, the agent achieved 70.2% on SWE-bench Verified, compared with 70.0% when retaining the full conversation history.

Even more interesting, median peak context dropped from 32K tokens to 8K tokens.

That’s a 75% reduction in median peak context with almost identical benchmark performance.

The research paper is called You Don’t Need Long Context.

For developers building AI agents, this raises an interesting engineering question:

Are we giving AI agents too much conversational history when they only need a small amount of useful state to continue working?

Let’s understand what the researchers tested, why it works, and how you can apply the same idea when building your own AI agents.

1. The problem with giving agents unlimited conversation history

Most AI agents follow a conversational execution loop.

A user provides a task, the model reasons about it, calls tools, receives results, and continues until it completes the task.

For example, consider an AI coding agent fixing a failing test.

Its conversation might look something like this:

User: Fix the failing authentication test.
Agent: I will inspect the authentication module.
Tool: Read auth.ts
Agent: The token validation logic looks suspicious.
Tool: Run authentication tests.
Tool: Tests failed.
Agent: I will try updating the expiration check.
Tool: Apply code changes.
Tool: Run tests again.
Agent: The issue appears to be related to timezone handling.

Every interaction becomes part of the conversation history.

When the model makes its next decision, the agent framework may send the previous messages again as context.

This creates a problem as the task gets longer.

  • Earlier file contents remain in the conversation.

  • Failed experiments continue consuming context.

  • Tool outputs accumulate.

  • Repeated observations occupy tokens.

  • The model has to process an increasingly large history.

Eventually, the agent approaches its context window limit.

Even when the model supports a large context window, sending more information has consequences.

You may pay for additional input tokens, increase processing requirements, and spend more time managing context.

There is also a practical concern: important information can become harder to distinguish from the accumulated history.

The obvious solution seems to be summarization.

However, NVIDIA’s research explores a more interesting approach.

2. What if an agent started a fresh conversation after every action?

The central idea behind the paper is simple.

Instead of continuously extending the conversation, the agent maintains a compact record of its current state.

After an action, the agent updates that record and starts a fresh conversation.

The next model call receives the task and the updated state instead of the entire conversation history.

Consider the previous coding example.

After investigating the authentication failure, the agent might preserve this record:

Task:
Fix the failing authentication test.

Confirmed findings:
- Token expiration validation uses local time.
- The failing test expects UTC-based validation.
- The issue is in auth.ts.
Failed approaches:
- Changing the expiration threshold did not fix the test.
- The problem is timezone conversion, not token duration.
Current progress:
- Root cause identified.
- Fix is partially implemented.
Next action:
- Complete the UTC conversion.
- Run authentication tests.
- Verify related test cases.

The next model call receives this information.

It doesn’t need to read the entire investigation again.

It already knows what happened, what was discovered, and what needs to happen next.

This is the central idea: preserve the information required for the next decision, rather than preserving every previous interaction.

3. Understanding the two approaches tested

The paper investigates different ways to manage an agent’s context.

Two approaches are particularly relevant to developers building agent frameworks.

Approach 1: Periodic compaction

In periodic compaction, the conversation grows normally until it reaches a predefined threshold.

The agent then produces a compact representation of its progress.

The framework starts a fresh conversation using that representation.

For example:

Conversation 1
    |
    | Execute multiple actions
    |
    v
Context reaches threshold
    |
    v
Generate compact state
    |
    v
Start fresh conversation
    |
    v
Continue execution

This approach allows the agent to retain its conversation history for several actions before compressing it.

It can be useful when earlier interactions contain information that remains relevant across multiple steps.

Approach 2: One action per conversation

The second approach is more aggressive.

After every action, the agent updates its state and starts a new conversation.

The execution looks like this:

Conversation 1
    |
    v
Execute one action
    |
    v
Update state
    |
    v
Conversation 2
    |
    v
Execute one action
    |
    v
Update state
    |
    v
Conversation 3

Every model invocation starts with a relatively small context.

This is the approach behind the opening experiment.

The agent continuously carries forward its progress through a compact written record.

There is an important implementation detail here.

Starting a fresh conversation does not mean restarting the actual task.

For a coding agent, files modified on disk remain modified. Git changes remain available, and external tool state can persist.

The conversation is disposable. The working environment can remain intact.

That separation makes this architecture practical.

4. The difference between conversation history and agent state

This is probably the most useful concept for developers working on AI agents.

Conversation history and agent state are two different things.

Conversation history describes everything that happened during execution.

Agent state describes what the system currently knows and what it needs to do next.

Consider an agent that has investigated a bug for 20 minutes.

Its conversation history might contain:

  • 15 file reads.

  • 8 terminal commands.

  • 4 failed experiments.

  • Several explanations.

  • Multiple tool responses.

Its current state might require only:

{
  "task": "Fix authentication test failure",
  "rootCause": "Incorrect timezone conversion",
  "relevantFiles": ["auth.ts", "auth.test.ts"],
  "completed": [
    "Identified failing test",
    "Confirmed timezone issue"
  ],
  "pending": [
    "Complete UTC conversion",
    "Run authentication tests"
  ],
  "constraints": [
    "Do not change token expiration semantics"
  ]
}

The JSON above is an illustrative state representation, not a format prescribed by the paper.

Notice how much smaller the state is compared with the conversation.

It contains the information needed to continue execution.

This distinction changes how we should design agent frameworks.

Instead of treating chat messages as the permanent storage mechanism for everything an agent learns, we can maintain an explicit execution state.

The model can reconstruct its immediate working context from that state whenever necessary.

💡 Enjoying this article?
Every week day, I publish practical, production-ready deep dives covering Web development, System Design, Open source projects, Tech industry trends and AI Engineering and tools.

5. How to implement context compaction in your own AI agent

Let’s translate this research into a practical architecture.

Suppose you are building a coding agent using JavaScript or TypeScript.

Your agent needs four major components:

  1. Task definition.

  2. Tool execution.

  3. State management.

  4. Context reconstruction.

The execution process could look like this:

interface AgentState {
  task: string;
  findings: string[];
  completedActions: string[];
  failedAttempts: string[];
  pendingActions: string[];
}

async function runAgent(task: string) {
  let state: AgentState = {
    task,
    findings: [],
    completedActions: [],
    failedAttempts: [],
    pendingActions: []
  };
  while (true) {
    const response = await callModel({
      task,
      state,
      conversationHistory: []
    });
    const result = await executeAction(response.action);
    state = await updateAgentState(state, {
      action: response.action,
      result
    });
    if (response.action.type === "complete") {
      break;
    }
  }
}

This is a simplified architectural illustration. A production implementation would also need action validation, error handling, termination conditions, and persistence.

The important part is that each model invocation receives the current state rather than an ever-growing conversation history.

Step 1: Define what your agent should remember

Start by identifying the information required to continue the task.

For a coding agent, this could include:

  • Original user requirements.

  • Relevant files and code locations.

  • Confirmed findings.

  • Failed approaches and their reasons.

  • Current implementation status.

  • Remaining tasks.

  • Constraints and acceptance criteria.

Avoid storing every observation by default.

For example, a terminal command returning 200 lines of output might contain only one useful finding.

Preserve that finding and keep the original output available through your execution logs.

Step 2: Generate a structured handoff

After an action, update the agent state.

A good handoff should answer three questions:

  • What has the agent established?

  • What has it already changed?

  • What should it do next?

The quality of this handoff determines whether the next model invocation can continue correctly.

A vague summary such as “Investigated the problem and made progress” is almost useless.

The next model needs actionable information.

Step 3: Reset the conversation

This is where many implementations can make a mistake.

Suppose you generate a compact summary but continue sending the original conversation history to the model.

You haven’t reduced the context.

You have simply added another message.

The framework must actually replace the old conversation with the new task context and compact state.

Step 4: Preserve the execution environment

The agent’s conversation and its working environment should have independent lifecycles.

This gives the agent a clean conversational context while preserving the work it has already completed.

6. The biggest risk: losing important information during compaction

There is a reason this approach deserves careful testing.

A compact state can accidentally remove information that the next action depends on. The paper reports a particularly interesting result with Qwen 3 Coder Next.

Its SWE-bench Verified score dropped from 53.0% to 3.6% under the paper’s tightest periodic compaction setting.

That’s a substantial performance decline. It tells us that aggressive context reduction can affect different models very differently.

Imagine this scenario:

An agent tries three approaches to fix a database migration. All three fail for different reasons.

During compaction, the agent records only:

Database migration is failing.

The next model invocation has lost the reasons behind those failures. It might repeat the same experiments.

A better state would preserve:

Attempt 1:
Changed the column type. Failed because existing records
contain incompatible values.

Attempt 2:
Added a default value. Failed because the migration runs
before the required column is available.

Attempt 3:
Modified the migration order. Failed because another
migration depends on the original schema.

Current conclusion:
Investigate migration dependencies before attempting
another schema change.

The lesson is straightforward: a shorter state is useful only when it preserves the information required for future decisions.

For production agents, I would also recommend keeping the original execution traces.

The compact state can serve as the working memory, while the full logs remain available when the agent needs to inspect an earlier result.

7. Does shorter context actually reduce API costs?

This is where developers need to look beyond token counts.

The NVIDIA experiment reports a reduction in median peak context from 32K to 8K tokens.

That is encouraging, but a smaller context does not automatically translate into an equivalent reduction in API spending.

Context compaction introduces additional work.

For example:

  • The agent needs model calls to update its state.

  • Repeated calls may reduce prompt-cache reuse.

  • Summarization itself consumes tokens.

  • Poor handoffs can cause the agent to repeat earlier investigations.

A system that uses fewer tokens per request might still spend more overall if it needs additional requests to finish the task.

Therefore, measure the complete execution.

I would start with a simple A/B experiment.

Run the same set of tasks using:

  1. Full conversation history.

  2. Periodic context compaction.

  3. One action per conversation.

Compare successful task completion and total cost.

A configuration that reduces context by 75% but causes more failed tasks is unlikely to be a good trade-off.

8. What this means for the future of AI agent architecture

This research has practical implications for anyone building AI-powered developer tools, autonomous coding agents, research agents, or multi-step workflows.

Agent frameworks have traditionally relied heavily on conversation history to maintain continuity.

The experiment suggests that explicit state management deserves more attention.

There are several interesting applications:

Coding agents: Preserve implementation progress, test results, file references, and unresolved issues between model invocations.

Research agents: Keep research findings and source references in a structured state instead of repeatedly sending entire documents.

Browser agents: Preserve completed steps, extracted information, and the next intended action while maintaining browser state.

Multi-step automation: Store workflow progress independently from the conversation so execution can resume after interruptions.

There is also a useful architectural separation emerging here:

  • The model handles reasoning and decision-making.

  • The tools interact with the external environment.

  • The state store maintains execution progress.

  • The agent harness controls context construction and lifecycle.

This separation makes agent execution easier to inspect and test.

It also gives developers more control over what information reaches the model on each invocation.

Conclusion

The NVIDIA experiment challenges an assumption that has influenced many conversational AI systems: an agent needs its entire history to continue working effectively.

In the reported Claude Opus 4.5 experiment, one-action conversations achieved 70.2% on SWE-bench Verified, compared with 70.0% for the full-history setup. Median peak context fell from 32K to 8K tokens.

Those results are worth paying attention to, although the Qwen results show that aggressive compaction can also cause serious performance regressions.

If you’re building an AI agent, try separating its conversation history from its execution state.

Start with one workflow, preserve the information needed for the next action, and compare the results against your existing implementation.

Your agent might be able to finish the same task with considerably less context.

And that is a much more useful engineering improvement than simply giving every agent a larger context window.

References

Thank You for Reading!

I hope you found it helpful and informative. If you have any questions or feedback, feel free to leave a comment below. Your support and engagement mean a lot to me.

Happy Coding!

Reply

Avatar

or to participate