CORVUS: Context Optimization and Reduction Via Underlying Synchronization for LLM Coding Agents

Mingwei Zheng, David OBrien, Siwei Cui, Pardis Pashakhanloo, Rajdeep Mukherjee, Myeongsoo Kim, Sachit Kuhar

TL;DR

Imagine trying to debug a codebase while only looking at printed screenshots of files you took twenty minutes ago—every time you edit a file, your printouts become obsolete, forcing you to print fresh copies that clutter your desk. That is essentially how standard LLM coding agents work today. CORVUS fixes this by replacing static file snapshots in the chat history with a live, auto-updating "synced workspace" at the end of the prompt, cutting token costs by up to half and speeding up execution without sacrificing accuracy.

What Problem Does This Paper Address?

Modern AI coding agents (like Claude Code or Cursor) operate in a loop: they think, call a tool (like reading a file or running a test), observe the output, and append everything to an ever-growing conversation log called a trajectory.

The catch? Code files are mutable, while an append-only chat history is immutable. When an agent reads app.py, the file's entire text is pasted into the history as a frozen snapshot. As the agent—or a human collaborator—edits that file, the historical snapshot goes stale. This creates two major headaches:

  1. Stale-context errors: The agent tries to edit lines based on an outdated snapshot, fails, and wastes turns diagnosing its own confusion.
  2. Duplicate file reads: To see the latest state (or because earlier reads got buried), the agent re-reads the file—26% of all file reads in one baseline were duplicates! Each re-read dumps another full copy into the prompt, driving up latency, cost, and context rot (where LLMs lose focus as prompts get bloated).
Figure 1: Append-only trajectories accumulate stale snapshots, causing redundant reads and erroneous writes. CORVUS maintains synchronized context, eliminating these inefficiencies by design.

Existing fixes are mostly reactive—waiting until the prompt gets huge and then summarizing or truncating older turns. The authors ask: instead of cleaning up bloat after the fact, why let stale duplicates enter the history at all?

Methods

CORVUS makes one clean, proactive architectural change: it decouples the act of requesting a file from storing its contents.

Instead of a standard read_file tool that dumps hundreds of lines of code directly into the chronological chat log, CORVUS gives the agent a sync_file tool.

  • Registration: Calling sync_file("a.py") simply adds a.py to a background registry (the synced file set) and leaves a tiny placeholder ("sync: a.py") in the chat history.
  • Context Synchronization: Right before each LLM reasoning step, a Context Sync phase fetches the fresh, current contents of every registered file directly from disk and appends them as a dedicated "Synced Context" block at the very end of the prompt.
Figure 2: CORVUS augments the standard Thought–Action–Result loop with a Context Sync phase (orange) that refreshes the agent’s context by fetching the latest contents of all relevant files before each reasoning step. The resulting synced context is appended to each prompt (orange), ensuring every reasoning cycle operates on an up-to-date repository snapshot.

By construction, the prompt contains at most one copy of any file, and it is guaranteed to reflect the exact current state of the repository.

Datasets

CORVUS is evaluated as an inference-time architecture (no model training involved) across 573 real-world software engineering tasks from two benchmarks extending SWE-bench:

  • SWE-PolyBench_Verified (382 tasks): Expands beyond Python into Java, JavaScript, and TypeScript, covering bug fixes, feature additions, and refactoring.
  • SWE-Bench Pro (191 sampled tasks): Targets complex, enterprise-grade tasks that take human engineers hours or days (averaging 107 lines changed across ~4 files). The authors specifically sampled tasks with above-average code changes to stress-test long-horizon context growth.

Key Insights and Ideas

  • Treat mutable state as mutable: Chat histories are great for recording a timeline of actions, but terrible for storing mutable state like source code. Separating event history from workspace state eliminates an entire class of edit errors.
  • Proactive beats—and boosts—reactive: Because CORVUS stops redundant snapshots upstream, it pairs naturally with downstream compression methods (like sliding windows, summarization, or observation masking). Combining them yields greater token savings than either approach alone.
  • Agents naturally keep small working sets: Even without a way to close files, agents only synced ~3 to 8 files per task on average. Refreshing a handful of local files takes milliseconds—far cheaper than the LLM inference turns saved by avoiding failed edits.

Key Results

Tested across four state-of-the-art models (Claude Sonnet 3.7, 4, 4.5, and open-source Qwen3-Coder-480B), CORVUS consistently trimmed the fat while preserving task success (pass@1 showed no statistically significant differences):

  • Fewer wasted steps: Duplicate file reads dropped by 22–86%, and total reasoning cycles fell by up to 37.3% (dropping from 45.0 to 28.2 cycles on Sonnet 4.5).
  • Leaner prompts & lower bills: Final prompt lengths shrank by 15–32%, and total input tokens dropped by 9–50%, cutting per-task API costs by up to 50.3% ($5.27 down to $2.62 on Sonnet 4.5).
  • Faster wall-clock runtime: End-to-end execution time improved across the board, up to 40% faster on Sonnet 4.5.

Limitations and Future Work

  • No "close tab" button yet: Once synced, a file stays in context for the rest of the task. Adding a desync_file tool or syncing only specific AST code blocks/functions could shrink prompts even further.
  • Friction with prefix caching: Standard LLM KV-caches rely on exact prompt prefixes. Because CORVUS places the Synced Context after the growing chat history, those file tokens shift position every turn, preventing prefix-cache hits on unchanged files. Emerging position-independent or modular caching schemes could unlock extra speedups here.
  • Out-of-distribution trajectories: Today's LLMs are trained on conventional read_file logs; fine-tuning models specifically on synced-context trajectories could help them manage their working sets even more effectively.

Summary updated

Abstract

LLM coding agents operate by constructing trajectories that accumulate reasoning, tool calls, and results to enable multi-step decision-making. However, the conventional append-only trajectory architecture found in practice tightly couples file-read actions with their observations, capturing snapshots that become permanently fixed in the chronological history. As files change through agent edits or concurrent human modifications, these snapshots become stale, causing reasoning errors and causing agents to redundantly re-read files, with each re-read appending yet another copy to the trajectory. To mitigate this, we propose CORVUS, a novel trajectory architecture that decouples file-read actions from their observations by maintaining a synchronized registry of relevant files and injecting only their current contents at each reasoning cycle. This structural change produces significantly lighter-weight trajectories that remain synchronized with the actual codebase state by construction, eliminating redundant file copies and stale snapshots that bloat conventional trajectories. We evaluated CORVUS on SWE-POLYBENCH_VERIFIED and SWE-BENCH PRO across four LLMs, achieving 9–50% reduction in average input tokens per task, 15–32% shorter final prompts, and up to 37% fewer reasoning cycles while maintaining comparable pass rates.
BibTeX
@inproceedings{zheng2026corvus,
  author = {Mingwei Zheng and David OBrien and Siwei Cui and Pardis Pashakhanloo and RAJDEEP MUKHERJEE and Myeongsoo Kim and Sachit Kuhar},
  title = {{CORVUS: Context Optimization and Reduction Via Underlying Synchronization for LLM Coding Agents}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=sxZjrxwU2k},
}
Figure