NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Spine: Compiling Subtask Trees into Structured Context for Long-Horizon Coding Agents

Jiahong Xiang, Kunqiu Chen, Lingming Zhang, Yuqun ZhangarXiv 2026

TL;DR

Spine is a novel context-management framework that helps AI coding agents handle long, complex tasks by organizing their work into a structured "tree" of subtasks. By replacing the messy details of finished subtasks with concise results while keeping active tasks detailed, Spine significantly boosts agent performance and slashes costs—achieving results comparable to multi-agent systems at a 73.7% lower price point.

What Problem Does This Paper Address?

Building software isn't a linear process; it’s a hierarchy of nested subtasks. For example, while migrating a database, an agent might need to pause, run a compilation check, fix a small syntax error, and then resume the migration.

Current LLM agents struggle with this "long-horizon" work in two main ways:

  1. Context Inflation: They record every single interaction in a flat, chronological history. This quickly fills up the model's "memory" (context window), leading to slower performance and "forgetfulness."
  2. The Compression Dilemma: Existing solutions either trim the history (risking the loss of vital info for unfinished tasks) or delegate every subtask to a new "child" agent. Delegation adds massive coordination overhead and prevents "prefix caching"—a trick used by LLM providers to speed up processing by reusing previous computations.

Methods

The authors introduce Spine, which treats the agent's interaction history not as a flat log, but as a SpineTree.

  • Work Scopes: The agent uses explicit commands (Open, Close, Next) to define subtask boundaries. This allows the same agent to dive into a subtask and "surface" back to the parent task once finished.
  • Just-In-Time (JIT) Compilation: Before every call to the LLM, the Spine runtime "compiles" the SpineTree into a prompt. Crucially, it keeps the full interaction history for the active subtask but replaces the bulky details of completed subtasks with just their final results.
  • Prefix Cache Preservation: Because the "parent" context remains unchanged while the agent works on a "child" subtask, the system maximizes the reuse of KV-caches (Key-Value caches), making the process much more efficient.
Overview of the Spine runtime and context compilation process.

Datasets

The researchers evaluated Spine across three rigorous benchmarks designed for long-term software engineering:

  • SWE-Milestone: Focuses on continuous repository evolution (98 milestones).
  • ProgramBench: Requires reconstructing entire programs from documentation.
  • FrontierSWE: Covers open-ended, complex engineering and research tasks.

They tested these using top-tier models including GPT-5.6 Sol, Grok 4.6, Gemini 3.8 Flash, and the open-weight Qwen 3.8 27B.

Key Insights and Ideas

  • Decoupling Granularity from Delegation: You don't need a new agent just because you have a new subtask. Spine allows a single agent to manage its own "mental" hierarchy, reducing the "communication tax" of multi-agent systems.
  • Structural Alignment: By forcing the context to match the task's logical structure (the tree), the model is less likely to lose track of progress or repeat work it has already done.
  • The "Nushell" Case Study: The paper illustrates how an agent migrating the Nushell codebase can finish a "compilation check" subtask and return a simple "tests passed" result to its main context. This prevents the model from being distracted by hundreds of lines of compiler output while it tries to finish the main migration.
Fig. 2. History compression and recursive delegation during the Nushell migration.

Key Results

  • Better Performance: Integrated into the Codex harness (SpineCodex), it improved the SWE-Milestone score by 11.8% and the ProgramBench pass rate by 17.3% using GPT-5.6 Sol.
  • Massive Cost Savings: SpineCodex reduced total monetary costs by 32.4% compared to native Codex. Even more impressively, it matched the performance of "Recursive Subagent" systems while being 73.7% cheaper.
  • Generalizability: When added to the open-source Pi harness, Spine improved scores by up to 17.5% across different models, proving it isn't tied to a single architecture.

Limitations and Future Work

  • Agent Command Following: Spine relies on the agent's ability to correctly use Open and Close commands. While the models tested handled this well, smaller or less capable models might struggle with the added "lifecycle" overhead.
  • Environment Constraints: Some tasks in the FrontierSWE benchmark were unavailable due to specific hardware or API requirements (like H100 GPUs or external Tinker APIs), limiting the scope of that specific evaluation.
  • Future Directions: The authors suggest that future work could involve more automated ways for agents to discover and define their own subtask boundaries without explicit commands.

Summary updated

BibTeX
@misc{xiang2026spine,
  author = {Jiahong Xiang and Kunqiu Chen and Lingming Zhang and Yuqun Zhang},
  title = {{Spine: Compiling Subtask Trees into Structured Context for Long-Horizon Coding Agents}},
  year = {2026},
  eprint = {2610.37224},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/2610.37224},
}
Figure