Long-horizon coding tasks contain nested subtasks. Typically, agents record interactions sequentially into a growing history, causing context inflation and performance degradation. Compressing or trimming the history without explicit subtask boundaries can discard information needed by unfinished subtasks. Conversely, recursive subagent delegation isolates completed subtasks through child agents by assigning every subtask boundary to delegation, which conflates subtask granularity with executing agent choice, adding execution and coordination overhead. We introduce Spine, an interface and runtime that align model context with subtask nesting and completion. An agent declares explicit subtask boundaries through work scopes, allowing the same agent to execute nested subtasks inline while reserving delegation for independent parallel tasks. The runtime organizes execution in SpineTree, a persistent tree recording subtask relations, local interactions, completion states, and returned results. Before each model call, it compiles the tree into model context just in time, retaining unfinished subtasks' interactions and replacing completed subtasks' details with their results, while preserving prefix-cache reuse. We integrate Spine into Codex to build SpineCodex. With GPT-5.6 Sol, compared with native Codex, SpineCodex improves SWE-Milestone Score by 11.8% while reducing total cost by 32.4%, improves the average ProgramBench test-pass rate by 17.3%, and improves Mean@5 on eight of the ten evaluated FrontierSWE tasks. On SWE-Milestone, it also achieves a comparable Score to Recursive Subagent at 73.7% lower total cost. We also integrate Spine into Pi through a reusable software package: with Gemini 3.8 Flash and Qwen 3.8 27B, it improves SWE-Milestone Score by 9.5-17.5% and the average ProgramBench test-pass rate by 4.3-8.7% compared with native Pi.
Figures & tables
Figure 1. Nested work within the Nushell migration. An illustrative decomposition of the migration contains a parser update with a nested compilation check, alongside other changes and workspace validation.
Figure 2. History compression and recursive delegation during the Nushell migration. The history-compression sequence inspects nine source files, reduces an inspection slice, then rereads overlapping ranges from seven of those files in each of two later responses. The recursive-delegation panel shows nested child executions and parent calls in one migration milestone: fourteen creation attempts, three blocked by the thread limit, eight status queries, twelve wait calls, eight messages, and six interrupts.
Figure 3. Returning nested results within the same agent. The compilation check completes inside the parser update. Its result replaces its details in subsequent context. The same agent continues the parser update, whose later result returns to the migration with other work still pending.
Figure 4. The coding-agent execution loop.
Figure 5. Overview of Spine . The Agent/Harness sends a turn stream and Open, Close, Next, and Spawn commands to the Compilation Frontend. Its SpineTree contains an open parent, a closed branch with retained task and child records plus a returned result, and an open child. The Compilation Backend maps these to parent continuation, returned result, and child instantiation, respectively, following the preceding context prefix. The resulting linear context goes to the Model API for the next turn. A dashed return path connects that turn to the Agent/Harness.
Command/event
Terminal stream ω
Work semantics
No command
P⋅O
Continue current work.
Open (d)
P⋅[Open(d)]⋅O
Enter inline child.
Close (μ)
P⋅[Close(μ)]⋅O
Complete child; return result.
Next (μ,d)
P⋅[Close(μ),Open(d)]⋅O
Close child; open sibling.
Spawn (tasks)
P⋅O⋅[SpawnNode(μi)]i=0k−1
Delegate tasks; collect results.
Table 1. Lifecycle commands and terminal streams. P and O encode preceding and current-turn messages; “ ⋅ ” denotes list concatenation; delegated results follow task order.
Figure 6. Context compilation for an illustrative diagnostic check. Three panels follow a parser update. The agent opens the parent work, records message m1, opens a diagnostic check, records a test call m2 and output m3, and closes the check with result mu before continuing with parent message m4. SpineTree retains m2 and m3 in the completed branch body F alongside mu. The next linear input contains the parent's task and identity D(p), m1, mu, and m4 in order.
Benchmark
Scope
Metrics
Target
SWE-Milestone ( Deng et al., 2026 )
7 tasks (98 milestones total)
Score (%) # Resolved
Continuous repository evolution
ProgramBench ( Yang et al., 2026a )
50 tasks randomly sampled from 200
# Resolved / # Almost Avg. pass (%)
Whole-program reconstruction
FrontierSWE ( Chu et al., 2026 )
10 tasks 5 trials/task
Mean@5 Best@5
Open-ended engineering
Table 2. Evaluation benchmarks and metrics.
SWE-Milestone
Model
Agent
Score (%)
# Resolved
Total tokens
Avg. input tokens/req.
Cost ($)
GPT-5.6 Sol
Codex
38.1
14/98
1,072.4M
131.2K
681.22
SpineCodex
42.6
19/98
640.5M
72.3K
460.77
Grok 4.6
Codex
35.5
12/98
713.8M
120.0K
505.57
SpineCodex
40.4
14/98
444.2M
60.3K
314.20
Table 3. Performance of SpineCodex and Codex on SWE-Milestone and ProgramBench.
GPT-5.6 Sol
Grok 4.6
Task
Codex
SpineCodex
Codex
SpineCodex
Mean@5
Best@5
Mean@5
Best@5
Mean@5
Best@5
Mean@5
Best@5
cranelift-codegen-opt
0
0
0
0
0.0164
0.0822
0
0
dart-style-haskell
0.1533
0.4029
0.4019
0.8136
0.0876
0.1595
0.4074
0.8505
dependent-type-checker
1.8420
3.6100
2.4750
3.7400
0
0
0
0
ffmpeg-swscale-rewrite
0.5472
1.6400
0.9488
1.7200
0.2140
0.6280
0.3910
0.6550
Table 4. Per-task performance of SpineCodex and Codex on FrontierSWE.
Agent
Score (%)
# Resolved
Total tokens
Avg. input tokens/req.
Cost ($)
Codex
38.1
14/98
1,072.4M
131.2K
681.22
AgentDiet
36.5
12/98
959.2M + 76.0M *
92.8K
1,057.08 + 41.44 *
Context Folding
37.1
13/98
765.2M
87.3K
596.25
Recursive Subagent
42.4
17/98
2,139.9M
65.3K
1,749.73
SpineCodex
42.6
19/98
640.5M
72.3K
460.77
Table 5. Comparison with context-management approaches on SWE-Milestone using GPT-5.6 Sol.
Figure 7. (a) Repeated source inspection with AgentDiet ; (b) delegation with Recursive Subagent .
SWE-Milestone
Model
Agent
Score (%)
# Resolved
Total tokens
Avg. input tokens/req.
Cost ($)
Gemini 3.8 Flash
Pi
35.8
13/98
6,950.27M
511.06K
644.21
SpinePi
39.2
15/98
3,126.11M
164.31K
351.55
Qwen 3.8 27B
Pi
30.9
8/98
1,996.97M
132.46K
—
SpinePi
36.3
14/98
2,252.80M
148.73K
—
Table 6. Performance of SpinePi and Pi on SWE-Milestone and ProgramBench.
Figure 8. Runtime behavior of SpineCodex : (a) lifecycle calls; (b) input-token changes at returns. Accepted Open, Close, Next, and Spawn calls across seven projects, and distributions of input-token changes at return boundaries.
Figure 9. Nested returns during the Nushell migration with SpineCodex . An inner scope returns to language/parser work, which later returns to the migration; each parent receives a result and continues pending work.
Configuration
Score (%)
Resolved
Tokens
Avg. input
Cost
Navidrome, 9 milestones
SpineCodex
36.4
3/9
60.46M
71.2K
$42.48
Depth 1
28.6
2.33/9
71.50M
99.5K
$52.60
No boundary maintenance
29.0
2.33/9
67.40M
124.2K
$60.50
ripgrep, 11 milestones
SpineCodex
72.4
5.667/11
48.22M
59.8K
$34.67
Table 7. Ablation of nesting and boundary maintenance on three SWE-Milestone tasks.
How can language model agents effectively leverage libraries of reusable knowledge to solve long-horizon tasks? Recent work has increasingly focused on agent skills: reusable capabilities represented as skill packages, i.e., multi-file bundles containing instructions, scripts, and other resources that help agents perform specific tasks. Agent skills are typically executed by loading their skill instructions into an agent's context and relying on the agent to follow them. As task horizons grow, however, this approach becomes increasingly brittle, because reasoning quality degrades as more information accumulates in the context window. We investigate an alternative approach in which skill packages are instead invoked as subagents. Rather than loading skill instructions into the main context, subagent execution spawns fresh context windows dedicated to solving individual subtasks. We show that subagent execution outperforms agent-skill execution when skill packages expose clear input-output contracts and their instructions encode the procedural knowledge needed to fulfill those contracts. The tradeoff is additional communication overhead, as extra tokens are required to coordinate between the main agent and its subagents. Our results show that the benefit of reusable knowledge depends not only on its content, but also on how it is organized and invoked.
Wasu Top Piriyakulkij, Rachel Lawrence, Alicia Curth +2
Recursive language models (RLMs) showed that recursion over model calls is an effective strategy for long-context reasoning, and production coding agents have begun to write code that spawns subagents at scale, most recently in Anthropic's dynamic workflows. We name and study the pattern between these two lines of work, where the recursive unit is a full agent harness with filesystem tools, code execution, and planning rather than a model call with no tools. We call this the Recursive Agent Harness (RAH) and frame it as harness recursion, the code-first extension to the model recursion of RLMs. A parent agent generates and runs an executable script that spawns subagent harnesses in parallel for fine-grained workloads and uses structured function calls for small subtasks. We provide a controlled evaluation on long-context reasoning. With the backbone held fixed at GPT-5 to match the published Codex and RLM baselines, RAH improves the Codex coding-agent baseline from 71.75% to 81.36% on Oolong-Synthetic (199 samples, 13 context-length buckets up to 4M tokens), a gain attributable to the harness rather than the model. With a stronger backbone, Claude Sonnet 4.5, the same design reaches 89.77%.
Coding agents re-send large file reads and tool outputs to a frontier LLM every turn, and this context dominates their token bill. General-purpose prompt compressors are trained on prose and suit code poorly: they paraphrase identifiers and drop the exact spans an agent needs to edit. We present Paritok-4B, a 4B LoRA compressor for coding-agent trajectories built on two commitments. It is extractive: it selects spans rather than rewriting them, and 96.0% of the identifiers, paths, and numbers it emits already appear in its input, holding at 96.2% on held-out SWE-bench Lite output. It is intent-conditioned: told the agent's current task, it acts chiefly inside a retained segment, selecting which lines survive (retained lines are +0.067 more intent-relevant than removed ones, paired 95% CI [+0.056, +0.078]) rather than changing how much is retained. We distil a gpt-4.1-mini teacher over 67,074 real OpenHands trajectories into 40,606 validated examples and fine-tune Qwen3-4B. On all 300 SWE-bench Lite instances, Paritok-4B compresses agent context to 25.7% of its size, 2.0x harder than a gpt-4.1-mini compressor (50.2%) and 2.4x harder than gpt-5 (61.9%), while retaining 86.5% of uncompressed single-shot solve quality. Fed the cat -n line-numbered input real agents produce, it compresses slightly less (27.8%) and retains more (89.3%); there the paired test is informative, with 30 instances solved only uncompressed and 17 only compressed, an exact McNemar p=0.079, so at this sample size compressing context to roughly a quarter of its size does not significantly reduce the solve rate. The model is a 264 MB adapter that self-hosts on one 24 GB GPU with no per-token compressor fee, which at list prices decides the economics: gpt-5 as a compressor is net-negative, costing more than the downstream tokens it saves. Weights, data, and evaluation scripts are open (Apache 2.0).