Source-linked AI summary

Trained Agentic Context Management

Bryce Sandlund

arXiv:2610.02404v1cs.LGcs.CL

TL;DR

Hard context limits motivate alternatives to native scaling and handcrafted harnesses for long-document tasks. The paper fine-tunes Qwen3.6-35B-A3B on diverse synthetic data using a simple agentic harness; with 8K tokens per agent, it matches GPT-5.4’s 1M-token-context OOLONG-synth performance above 40K document length.

  • Problem

    The paper asks whether models can learn to manage context effectively instead of relying on native context scaling or human-authored harnesses.

    Source: §1 · pp. 1–2
  • Method

    The authors fine-tune Qwen3.6-35B-A3B on diverse synthetic data, training decomposition and delegation strategies without hardcoding the decomposition structure in the harness.

    Source: §1.2 · p. 2, §3 · pp. 4–5
  • Results

    With 8K tokens per agent, the model matches GPT-5.4 with 1M tokens of context on OOLONG-synth when document length exceeds 40K tokens.

    Source: §1.2 · p. 2
  • Takeaways & Limitations

    The authors frame agentic training as an alternative to runtime harness engineering and excessive native long context.

    Source: §5 · p. 7

    A production training recipe would require a wider training distribution, and the attempted reinforcement-learning stage produced high-variance policies that weakened overall performance.

    Source: §3 · p. 6, §5 · p. 7

Abstract

from arXiv · show

We study long context language models. Instead of training long context natively, or designing a long context harness, we train a model over the simplest possible harness: a tool to call itself with any specified prompt and a tool to read tokens in a range from the input context. We finetune Qwen3.6-35B-A3B on a diverse synthetic dataset using this harness. With only 8,000 tokens of context, our small model is as strong as GPT-5.4 with 1M tokens of context on the OOLONG-synth benchmark when document length exceeds 40K tokens.

1 INTRODUCTION

Hard context limits motivate alternatives to native scaling, including training models to manage context through an agentic harness. The paper reports strong long-document benchmark performance from a fine-tuned model using only 8K tokens per agent.

1 INTRODUCTION

  • Context length is a hard resource limit, even as model builders tout windows of 10M and 100M tokens.Source: §1 · p. 1
  • Prior approaches use recursive summarization, external memory, and REPL-based repeated calls [Zhang et al., 2025] for long-document tasks.Source: §1 · pp. 1–2
  • The paper asks whether context management can be trained instead of relying on human-authored harnesses, and answers affirmatively with a harness intended to enable capability without fixing choices.Source: §1 · p. 2

1.1 HARNESS

  • The harness lets the model read a token range and spawn a fresh-context copy with a specified subtask; prompts are passed over the document through these tools.Source: §1.1 · p. 2

1.2 RESULTS

  • With 8K tokens per agent, the model matches GPT-5.4 with 1M tokens of context on OOLONG-synth above 40K document length; on RULER, it scores ≥85% from 10K to 320K.Source: §1.2 · p. 2

2 RELATED WORK

Related work spans native long-context models, context compaction, and harnesses that use independent model calls. The paper situates its approach among these alternatives and prior agentic systems.

2 RELATED WORK

  • Long-context work is divided into native context models, context compaction, and long-context harnesses, both trained and untrained.Source: §2 · p. 2

2.1 NATIVE LONG CONTEXT MODELS

  • Transformer attention has Ω(n^2) complexity, while hybrid architectures combine linear or sparse attention with dense layers to support context lengths of 1M+ tokens.Source: §2.1 · p. 3

2.2 CONTEXT COMPACTION

  • Context compaction maps current context x to a much smaller y through masking, summarization, or learned compaction.Source: §2.2 · p. 3

2.3 LONG CONTEXT HARNESSES

  • Long-context harnesses scaffold LLMs with tools and multi-agent systems; workflows such as MemGPT, RAPTOR, and Chain of Agents decompose documents for independent calls to read and aggregate.Source: §2.3 · p. 3
  • Memagent also uses an 8K-token context on long documents, but tests primarily on its training distribution, compares only small models, and hardcodes execution paths and prompts.Source: §2.3 · p. 3
  • Frontier systems also train multi-agent behavior, including Kimi K2.5’s agent swarm and OpenAI’s multi-agent work.Source: §2.3 · pp. 3–4

3 METHODS

The paper trains the model to choose and compose task-appropriate decomposition strategies using a minimal harness rather than hardcoding a workflow. Synthetic oracle demonstrations teach delegation across aggregation, retrieval, and sequential tasks.

Training strategy

  • The harness supports tree reduce for order-independent tasks, sequential fold for order-dependent tasks, and agentic delegation for boundary conditions, without hardcoding a decomposition structure.The model is trained to compose these strategies according to the task and its current problem-solving state.Source: §3 · p. 4

Decomposition strategies

  • Tree reduce delegates halves of the range down a tree; leaves compute chunk-level operations that are aggregated upward.This strategy is used for order-independent tasks such as aggregation and retrieval.Source: Figure 2 · p. 4, §3 · p. 4
  • Sequential fold processes slices in order, with each agent updating a running state before delegating the remaining document to the next agent.It is used for order-dependent tasks such as variable tracking.Source: §3 · p. 4, Figure 3 · p. 5

Boundary handling

  • Boundary agents own items that begin in their range and read 200-token increments until the final item is no longer cut off.These additional reads are omitted from the tree-reduce and sequential-fold figures for brevity.Source: §3 · p. 4, Figure 4 · p. 5

Training data

  • Synthetic oracle demonstrations cover aggregation, retrieval, and sequential tasks, with independent questions and more diverse examples than the evaluation distribution.The training challenge is teaching the model to delegate subtasks from which the final answer can be determined.Source: §3 · p. 5

Training strategy

  • The authors report that RL after SFT produced high-variance policies that latched onto simpler strategies and weakened overall performance.They suspect useful RL would require group-level baselines on subagent trajectories and more compute than the paper had available.Source: §3 · p. 6

4 EXPERIMENTS

The experiments compare the finetune with GPT-5.4 and base Qwen3.6-35B-A3B on RULER and OOLONG-synth across document lengths. The finetune matches GPT-5.4 on OOLONG-synth beyond 40K tokens, while remaining above 85% on RULER but below GPT-5.4.

Benchmarks

  • RULER evaluates long-context needle-style tasks including variable tracking, word frequencies, and question answering; OOLONG-synth queries aggregation over concatenated classification tasks.The OOLONG-synth tasks use ten underlying datasets.Source: §4 · p. 6

Evaluation setup

  • The evaluation samples five questions per RULER problem type and ten per OOLONG-synth family, and uses different temperature settings for the finetune, GPT-5.4, and base model.The finetune uses temperature 0.2, GPT-5.4 uses its API default, and base Qwen3.6-35B-A3B uses temperature 0.Source: §4 · p. 6

Results

  • Above 40K tokens, the finetune matches GPT-5.4 on OOLONG-synth; on RULER it remains above 85% but performs worse than GPT-5.4.The finetune uses an 8K-token per-agent context, while GPT-5.4 receives up to 1M tokens of context.Source: §4 · p. 6, Table 1 · p. 7

Efficiency

  • The authors describe the finetune as cheaper and faster than full-document comparisons, but do not formally quantify cost.They state complexity O(n) in document size versus Ω(n^2) for dense-attention architectures; the sampled base model is capped at 64K tokens.Source: §4 · pp. 6–7

Task-family results

  • Table 2 describes RULER common-word errors as worsening when fillers dilute those words, and OOLONG-synth leaf-classification and merge errors as compounding with length.The caption also notes distribution mismatch at 160K+ document length because training documents were at most 14K tokens.Source: Table 2 · p. 7

5 CONCLUSION

The paper argues that training on a bare-bones agentic harness lets a small-context model match a frontier model with 1M-token context on long-context evaluations. It frames this as a demonstration of agentic training, while identifying broader training data and reinforcement learning as future work toward a production recipe.

5 CONCLUSION

  • Training on a bare-bones agentic harness is sufficient for a small-context model to perform as well as a frontier model with 1M-token context on long-context evaluations.The authors say they do not claim full generalization, and did not train on their evaluation distributions.Source: §5 · p. 7
  • The authors argue these methods could be incorporated into frontier-model development to improve agentic performance under context pressure without wasting tokens, unlike an external harness applied at runtime.Source: §5 · p. 7
  • A production recipe would require a wider training distribution, and reinforcement learning would likely help develop agentic capabilities.The authors leave this work outside the scope of the paper and a small research project more generally.Source: §5 · p. 7
  • The authors used generative AI tools across coding, experiments, literature analysis, synthetic data, and other research tasks, reviewed the work, and take responsibility for the final content.Source: AI USE STATEMENT · p. 8

A HARNESS AND PROMPTS

The harness prompts distinguish root and subagent inputs while sharing a system prompt and tool descriptions. The full-document prompts provide the single-shot baseline, with RULER retaining its own context placement.

A HARNESS AND PROMPTS

  • Figure 5 shares the system prompt and two tool descriptions across root and subagents; the root receives the benchmark question, while a subagent receives its parent’s subtask.⟨N⟩ denotes document length and ⟨B⟩ the per-agent context budget.Source: Figure 5 · p. 14
  • Figure 6 gives single-shot baselines the whole document in one user message without tools or budget prose, placing RULER’s document at its template’s {context} position.Source: Figure 6 · p. 14
  • Table 3 places task context in the system prompt so every subagent inherits it without the parent restating it.For RULER, the template’s {context} position is replaced with instructions to use the separate document and its length.Source: Table 3 · p. 15
  • Table 4 counts the entire rendered conversation against an agent’s budget, while a subagent returns only boxed content to its parent.Each generation is capped at the remaining room, and the child’s reads and reasoning therefore do not enter the parent’s context.Source: Table 4 · p. 15

B TRAINING DATA

The training data covers aggregation, retrieval, and sequential tasks, with tree and fold structures for dividing work across agents. Training also varies prompts and context budgets, with documents typically longer than the budget.

B TRAINING DATA

  • Table 5 defines tree tasks as recursive halving with parents merging child partials, and fold tasks as agents passing a document remainder and accumulator sequentially.For retrieval in a tree, the half containing the answer wins; every tree agent is a training example.Source: Table 5 · p. 16
  • Training uses context budgets of 3K (50%), 5K (15%), 8K (13%), 10K (11%), and 12K (11%) tokens, with documents typically longer than the budget and lengths from 4K to 14K.Source: B TRAINING DATA · p. 17
  • The training setup upweights root gradient mass 4x and positive NarrativeQA leaves 2x, downsamples negative leaves by half, and jitters task and system prompts.The high-level task descriptions are given in Table 5.Source: B TRAINING DATA · pp. 16–17

C TRAINING DETAILS

The model is finetuned with rank-32 LoRA and cross-entropy loss on assistant tokens, using small batches and a single training epoch. The optimizer uses fixed Adam settings and a constant learning rate.

C TRAINING DETAILS

  • Training applies rank-32 LoRA to Qwen3.6-35B-A3B with the qwen3_5_disable_thinking chat renderer and cross-entropy loss on assistant tokens.Source: C TRAINING DETAILS · p. 17
  • Batch sizes range from 8 to 64, and training runs for a single epoch.Source: C TRAINING DETAILS · p. 17
  • The runs use pure Adam with no weight decay or gradient clipping, ϵ = 1e-12, β1 = 0.9, β2 = 0.95, and a constant learning rate between 5e-6 and 1e-5.Source: C TRAINING DETAILS · p. 17
Loading 2610.02404v1…