ACC: Compiling Agent Trajectories for Long-Context Training

Qisheng Su, Zhen Fang, Shiting Huang, Yu Zeng, Yiming Zhao, Kou Shi, Ziao Zhang, Lin Chen, Zehui Chen, Lijun Wu, Feng ZhaoarXiv 2026

TL;DR

Standard agent training suffers from a "supervision blind spot" because it masks out environment responses, missing a golden opportunity to teach LLMs long-context reasoning. This paper introduces Agent Context Compilation (ACC), a simple method that flattens multi-turn agent trajectories into long-context QA pairs. By training on this recycled data, a 30B model achieves long-context reasoning performance comparable to a 235B model without sacrificing its general capabilities.

What Problem Does This Paper Address?

As LLM-based agents tackle increasingly complex tasks, they generate massive multi-turn trajectories filled with tool calls, database queries, and web searches. Intuitively, these logs are a goldmine for long-context training. However, standard Supervised Fine-Tuning (SFT) practices completely ignore this potential. Standard SFT masks out the environment's responses and only calculates loss on the model's next-step tool selection.

The authors call this the supervision blind spot. Because the final answer's dependency on early tool observations is filtered through a long chain of intermediate steps, the gradient signal is heavily diluted. Consequently, models fail to learn how to synthesize information scattered across thousands of tokens. Existing fixes rely on expensive manual annotation or artificial text synthesis, which lacks the complex dependency structures of real-world problem-solving.

Methods

The authors propose Agent Context Compilation (ACC), a framework that transforms multi-turn agent logs into single-turn, long-context QA pairs. Instead of stepping through the trajectory turn-by-turn, ACC flattens the process:

  1. Context Assembly: It extracts all the essential evidence pieces (visited web pages, inspected code files, or queried SQL tables) from an agent's history.
  2. Permutation & Distractors: To prevent the model from relying on sequential bias, the evidence pieces are randomly shuffled. Irrelevant "distractor" files or unvisited search results are mixed in to increase the localization difficulty.
  3. Rationale Generation: Since raw agent logs lack explicit natural-language reasoning traces explaining how the final answer relates to the compiled context, the authors use a strong teacher model (DeepSeek-V3.2-Thinking) to synthesize answer-conditioned rationales.
  4. Direct Supervision: The model is trained on a single objective: given the original question and the flattened, compiled context, generate the reasoning trace and the final answer directly.
Figure 1: Overview of ACC. Multi-turn agent trajectories (Search, SWE, SQL) are compiled into long-context QA pairs by assembling tool responses and environment contexts.

Datasets

The authors compiled a training dataset of 10,802 trajectories across three distinct agent domains:

  • Search Agents: Multi-hop web search queries where evidence is scattered across multiple web pages.
  • SWE Agents: Software engineering tasks requiring the inspection and modification of codebase files.
  • SQL Agents: Relational database queries over complex schemas.

The resulting dataset features context lengths spanning from 2K to 128K tokens.

Figure 3: Token length distribution of the ACC train- ing data. We bin the samples by token count and plot the per-bin frequency for the training data compiled from each agent type.

For evaluation, they focused on long-range dependency benchmarks: MRCR (Multi-Round Coreference Resolution) and GraphWalks (graph traversal over extended text). They also monitored general capabilities using GPQA-Diamond, MMLU-Pro, AIME, and IFEval.

Key Insights and Ideas

  • Recycling over Synthesis: Instead of generating artificial long documents or paying humans to label data, ACC shows that agent logs—a natural byproduct of LLM deployment—are already rich in long-context reasoning patterns.
  • Task-Adaptive Attention Restructuring: Proving that the model didn't just learn a generic "look at everything" trick, mechanistic analysis revealed that the ACC-trained model dynamically restructures its attention based on the task. For graph traversal (GraphWalks), it increases attention to both local neighborhoods and distant nodes. For coreference resolution (MRCR), it sharpens its focus locally to verify candidates.
  • Expert Specialization: In Mixture-of-Experts (MoE) models, ACC training causes specific experts to specialize in long-context scanning and verification tasks, routing tokens differently depending on the nature of the long-range dependency.

Key Results

Fine-tuning the Qwen3-30B-A3B-Thinking model with ACC yielded massive improvements on long-context benchmarks, rivaling models nearly 8x its size:

  • MRCR: The overall score jumped from 50.19 to 68.28 (+18.09 points).
  • GraphWalks: Overall precision increased from 69.92 to 77.51 (+7.59 points).
  • These results are highly competitive with the much larger Qwen3-235B-A22B-Thinking model.
  • No Negative Transfer: Unlike many long-context tuning methods that degrade short-context reasoning, ACC preserved or slightly improved general capabilities (e.g., +2.49 on GPQA-Diamond and +1.50 on MMLU-Pro).
Table 2: Long-range dependency modeling benchmark results (avg@3). Numbers in parentheses show improvement over the Qwen3-30B-A3B-Thinking baseline. All results use default inference configurations without manual tuning of reasoning effort.

Limitations and Future Work

  • Scope of Evaluation: The method was validated on three specific agent types (Search, SWE, SQL) and a single model family (Qwen3). Its generalizability to other architectures or agent domains remains to be proven.
  • Context Window Scaling: While ACC successfully scales models up to 128K tokens, testing its limits on million-token contexts is left for future work.
  • Teacher Dependence: The rationale synthesis step relies heavily on a capable teacher model (DeepSeek-V3.2-Thinking), which introduces a risk of propagating biases or specific errors inherent to the teacher.
  • Data Safety: Reusing raw agent logs carries potential risks regarding privacy leaks and copyright infringement if the source trajectories contain sensitive or proprietary data.

Summary updated

BibTeX
@misc{su2026acc,
  author = {Qisheng Su and Zhen Fang and Shiting Huang and Yu Zeng and Yiming Zhao and Kou Shi and Ziao Zhang and Lin Chen and Zehui Chen and Lijun Wu and Feng Zhao},
  title = {{ACC: Compiling Agent Trajectories for Long-Context Training}},
  year = {2026},
  eprint = {2605.21850},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2605.21850},
}
Figure