Putting It All into Context: Simplifying Agents with LCLMs

Mingjian Jiang, Yangjun Ruan, Luis Lastras, Pavan Kapanipathi, Tatsunori Hashimoto

TL;DR

This paper challenges the prevailing trend of building increasingly complex, multi-step agent architectures for software engineering tasks. By leveraging Long-Context Language Models (LCLMs), the authors demonstrate that simply feeding an entire code repository directly into the model's context window—paired with simple prompting techniques—can match or outperform heavily engineered agent scaffolds on the SWE-bench Verified benchmark.

What Problem Does This Paper Address?

Building autonomous language model (LM) agents capable of solving complex, real-world tasks (like fixing bugs in large software repositories) has traditionally required highly complex architectures. Current state-of-the-art systems rely on elaborate "scaffolding"—custom toolsets, multi-agent coordination loops, external memory modules, and multi-stage retrieval pipelines.

The authors point out a fundamental flaw in this assumption: these complex pipelines are designed under the premise that the environment is only partially observable, requiring the agent to interactively explore it. However, for many tasks like repository-level bug fixing, the environment is actually fully observable from the start. With the advent of LCLMs boasting context windows of 1 to 2 million tokens, the authors ask a compelling question: Can we eliminate complex agent scaffolding entirely by simply putting the whole environment into the context window?

Figure 1: Overview. (Left) Traditional agent design treats the environment as partially observable and curates elaborate scaffolding (such as tools and execution pipelines) upon LMs to collect the necessary information for solving the task. (Right) In contrast, we leverage the increasingly powerful capabilities of long-context LMs to develop state-in-context agents that eliminate the need for complex scaffolding. These agents achieve full observability by maintaining the entire environment state within the context of LMs, turning open-ended agentic tasks into direct, close-ended tasks where LMs excel.

Methods

The authors introduce the concept of state-in-context agents and propose two primary workflows:

  1. DIRECTSOLVE: A pure, single-step approach where the LCLM receives the entire repository and directly outputs the solution patch. To make this work effectively, they identify two crucial prompting techniques:
  2. Code Restatement: The model is instructed to literally copy and restate the relevant code snippets before attempting the fix. This acts as an in-context retrieval mechanism and mitigates the well-known "lost in the middle" phenomenon.
  3. Chain-of-Thought (CoT) for Repair: The model decomposes its bug-fixing strategy into explicit reasoning steps before generating the final code diff.
  4. SELECTSOLVE: A hybrid, two-stage approach designed to combine the strengths of different models.
  5. Stage 1 (Localization): An LCLM reads the entire repository and identifies the top-$K$ most relevant files.
  6. Stage 2 (Repair): A highly capable Short-Context Language Model (SCLM), such as Claude-3.7-Sonnet, receives only those top-$K$ files to generate the final patch.

Additionally, because some massive repositories still exceed the 2-million-token limit, the authors implement a lightweight State Compression pre-processing step. An LCLM ranks folders and files based solely on the directory structure and the issue description. The system then filters out comments, docstrings, and non-target language files, sequentially filling the context window with the highest-ranked files.

Figure 2: Instantiation of state-in-context agents for software engineering. (Left) When the environment state (i.e., code repository) exceeds the context length limit of LCLMs, we apply a simple compression step that ranks files by their relevance and selectively includes files up to the maximum context limit. (Right) We instatiate state-in-context agents in two ways: DIRECTSOLVE directly generates the solution using LCLMs that consume the entire (compressed) state, which are then fed into short-context Language Models (SCLMs) to generate the solutions, leveraging the superior problem-solving capabilities of SCLMs.

Datasets

The approaches were evaluated on SWE-bench Verified, a rigorous subset of the original SWE-bench dataset. It consists of 500 software engineering problems drawn from 12 open-source Python repositories, where every problem and its corresponding evaluation patch have been verified by expert human annotators.

Key Insights and Ideas

  • Monolithic Simplicity Wins: Much like the historical shifts in computer vision and NLP where hand-crafted pipelines were replaced by end-to-end neural networks, agent design may be headed toward a monolithic future. A single LCLM can effectively trade off precision for perfect recall by having the entire codebase in-context.
  • Scaffolding is Brittle: Traditional scaffolding methods (like Agentless or CodeAct) are heavily optimized for specific models (e.g., GPT-4o). When the authors tried to directly transfer these complex pipelines to Gemini models, performance plummeted due to compounding parsing errors. The LCLM approach, by contrast, is highly robust and transfers easily across models.
  • The "Context Length Tax": Interestingly, the authors found that even when the necessary information is present in the prompt, model accuracy steadily degrades as the total context length scales up from 100K to 1M tokens. This highlights that while LCLMs are powerful, their ability to reason over massive contexts still faces architectural bottlenecks.

Key Results

  • Unscaffolded Superiority: When using the exact same underlying model (Gemini-1.5-Pro), the simple DIRECTSOLVE method achieved a 38.0% solve rate, significantly outperforming the adapted Agentless scaffolding baseline (32.0%) and CodeAct (18.8%).
  • Frontier Performance: By upgrading the single-step DIRECTSOLVE method to the more capable Gemini-2.5-Pro, the system directly attained a 50.8% solve rate without any tools or multi-step loops.
  • Hybrid Success: The two-stage SELECTSOLVE method combining Gemini-1.5-Pro (for localization) and Claude-3.7-Sonnet (for repair) achieved a highly competitive 48.6% solve rate.

Limitations and Future Work

  • Inference Cost: Currently, LCLM calls are expensive. Running DIRECTSOLVE costs an average of \$2.60 per instance compared to \$0.25 for the scaffolding-based Agentless. However, the authors note that implementing KV caching for repeated queries on the same codebase drops the marginal cost down to \$0.725, making it highly competitive as API costs continue to decline.
  • File Ordering Dependency: The performance of DIRECTSOLVE is highly sensitive to where the target files are placed in the prompt. Placing target files at the front yields a 32% pass@1 rate, which drops to 26% if placed at the end, confirming that LCLMs still struggle with uniform attention across massive contexts.

Summary updated

BibTeX
@misc{jiang2025putting,
  author = {Mingjian Jiang and Yangjun Ruan and Luis Lastras and Pavan Kapanipathi and Tatsunori Hashimoto},
  title = {{Putting It All into Context: Simplifying Agents with LCLMs}},
  year = {2025},
  eprint = {2505.08120},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2505.08120},
}
Figure