Reading Notes of ACM: Agentic Context Management for Long Horizon Tasks
I like the idea of insertion / deletion decisions of context management by on policy distillation, but there should be more analysis here. Also, the comparison is not fair. The compute is not saved. The paper just cares about compression, but not compute.
Reference: https://arxiv.org/abs/2607.23809
1. Motivation
Long growing context is verbose and noisy, leading to context limit hit and worse performance.
Three prior directions and why each falls short:
- Long-context pretraining. Extends the nominal window but shows measurable degradation inside it.
- Hybrid attention (Mamba-style, Jamba). Cheaper per token, still bounded by the same window.
- Context compression (ReSum, ACON, Claude auto-compaction). Actually shrinks the working set, but suffers two defects:
- Lossy. The compressed messages are deleted. If the summary drops a detail that turns out to matter at turn 60, it is gone.
- Externally triggered. Compression fires when a hand-written monitor sees usage cross a threshold, for example 90% of the window. That instant has nothing to do with where the agent is in its reasoning. It might fire mid-hypothesis, or fire far too late after the noise has already degraded 40 turns of decisions.
ACM: Makes context management an agentic decision rather than an externally-triggered one, allowing the agent to decide when and how to compress its context based on its reasoning state. Use on policy distillation to train the agent to learn when to invoke context management and when not to from super teacher models.
2. The ACM Framework
2.1 Base formulation
Let be the system prompt, an agent action (reasoning content plus tool calls), and the environment response at turn . The accumulated history is
and the agent policy together with the environment generate
The episode ends when the agent emits a finish action , or when where is the context limit (131,072 tokens in all experiments).
2.2 The Summary Agent baseline
An external monitor triggers once crosses a threshold. The environment returns and the history collapses to
Everything else is destroyed. This is the lossy, externally-triggered design ACM replaces.
2.3 The ACM Agent
Two tools are added to whatever task tools the benchmark provides.
manage_context takes no arguments. Let be the turn of the previous compression (with ) and the turn of the current call. The compressed segment is
A summarizer LLM produces , capped at 4096 tokens, structured as a Knowledge state section (facts with docid citations, live candidates, eliminated hypotheses, open sub-questions) and a Thoughts section (distilled recent reasoning plus one concrete next step). The raw block is written to disk under an identifier,
and the working context becomes
Note the system prompt and the original question are always preserved, and prior summaries remain in context. Only the raw span since the last boundary is swapped out.
query_memory(summary_id, query) hands the archived block plus a natural-language query to a querier LLM , which returns
formatted as compact bullets under three headings (relevant findings, dead ends, open and unresolved), with identifiers preserved verbatim. This is targeted recall, not reloading.
Define the compression ratio of a call as . In the paper’s case study and , giving .
2.4 Why this extends the exploration horizon (derivation)
The paper asserts this but does not derive it. Let be the average token cost of one turn.
Under ReAct the history is monotone, , so the episode dies at
Under ACM, compressing every turns at ratio , the persistent floor after cycles is and the peak inside a cycle is that floor plus . Termination requires
so total turns and
Two consequences follow directly. First, the horizon gain is governed by , not by , so ACM buys reach that a larger window cannot buy cheaply. Second, peak token usage is bounded by floor plus rather than by , which is why the paper claims reduced KV-cache pressure. The observed gain in the case study is only about rather than , because summaries accumulate monotonically and query_memory results add tokens back.
2.5 The two claimed properties
- Lossless. Raw messages are archived, not deleted, and are reachable at any later turn.
- Agent-initiated. Compression can fire at any point, so it tracks the reasoning state rather than a token counter, and it can fire before the history reaches its maximum, which is what relieves peak pressure.
Table 1 in the paper positions ACM as the only method satisfying all of {compact, trainable, lossless, agent-initiated, open data}.
3. Training Data Generation
3.1 Why training is needed at all
Figure 4 is the key evidence. Given the ACM toolset, GPT-5.5 calls manage_context 0.1 times and query_memory 0.0 times per question. Frontier models simply do not use the tools. Handing an agent a memory API is not enough. The timing policy has to be taught.
This also rules out the obvious data recipe. Distilling successful teacher trajectories fails because a strong teacher solves most problems without ever needing compression, so the demonstrations contain almost no positive examples of the target behavior. The data must come from student rollouts on problems the student cannot solve.
3.2 Dual-constraint teacher annotation
Phase 1, student rollout. The student runs each task twice, once without ACM tools producing , and once with them producing . captures ordinary exploration, captures untrained tool usage.
Phase 2, teacher annotation. A teacher receives prompt or , the matching trajectory, and the gold answer . The two constraints are applied crosswise.
-
Injection on (given , where compression should have happened). The teacher scans for the earliest turn showing redundant queries, cyclic exploration, or enough accumulated context to warrant compression, and replaces with a
manage_contextorquery_memorycall plus a first-person justification.Worked example from Figure 2. Original action reads "I should continue to search for … " followed by
<tool>search</tool>. The teacher rewrites it to “I notice my searches are starting to loop around the same broad clue set, road accident … I should compress what I have” followed by<tool>manage_context</tool>. The student was about to issue its fifth near-duplicate query. The label converts that into a compression. -
Refinement on (given , where compression should not have happened). The teacher finds premature calls and replaces them with a productive alternative, under a strict global priority: commit (the in-context evidence already answers the question), then replace with search (a novel query not already tried), then replace with get_document (fetch a docid already visible in a snippet).
Worked example. Original action reads “I should continue to compress the history…” followed by
<tool>manage_context</tool>. The teacher rewrites it to “Instead of compressing now, I should perform a targeted search for the book title, as it can directly address the residence-university aspect” followed by<tool>search</tool>. The student was compressing reflexively rather than making progress.
In both cases the student then resumes the rollout from , so the downstream trajectory is on-policy given the corrected decision.
3.3 On-policy distillation loss
A stronger teacher from the same family scores each student-generated assistant token with a soft next-token distribution, truncated to the top tokens and renormalized:
The objective is
where is a trajectory sampled from the student policy, is the set of assistant-token positions, and is the interleaved history. System prompt, user input, and tool-output tokens are masked out.
Derivation of what this optimizes. Per position, the forward KL from teacher to student is
Since does not depend on ,
So the loss is exactly forward-KL distillation, evaluated at states the student itself visits. Two design points matter. Forward KL is mode-covering, so the student is penalized for putting zero mass anywhere the teacher puts mass, which suits a decision with genuinely multiple acceptable continuations (search, compress, commit). And the states are on-policy, which is what fixes the compounding-error problem that plain behavior cloning on teacher trajectories would have. The gradient is not propagated through the sampling distribution that produced , so this is distillation on a periodically refreshed on-policy dataset, not a policy gradient.
3.4 Quality filtering
- Rejection sampling. Keep only tasks where the student failed all trials, so the model learns from the teacher on genuinely hard problems rather than on ones it already solves.
- Content filters. The teacher’s reasoning trace must justify the decision using structural cues only (repeated query keywords, token pressure, no new docids in the last turns) and must never leak , cite an unretrieved docid, or use coach-framing vocabulary (
feedback,advised,external,told me). Rationales are length-bounded to roughly 200 to 1500 characters and written strictly first-person. - Stabilizer. Original student rollouts are resampled and mixed in, STaR-style self-distillation.
4. Pseudocode
4.1 Inference
1 | |
4.2 Training
1 | |
5. Experimental Setup
Benchmarks.
| Benchmark | Role | Split | Tools |
|---|---|---|---|
| BrowseComp-Plus | in-domain search | 680 train, 150 eval | search over a fixed local corpus, get_document |
| DeepSearchQA | out-of-domain search, eval only | 17 domains, single-answer and set-answer | live web search, open |
| SWE-Bench Verified | coding | trained on SWE-Gym | execute_bash, str_replace_editor, submit_patch in a per-instance Modal sandbox at /testbed |
Simple tasks are deliberately excluded, since they finish before context pressure exists.
Models. Student policy, summarizer, and querier are all Qwen3.5-9B. Teacher is Qwen3.5-397B-A17B. Frontier reference points are Qwen3.5-397B-A17B and Gemini3-Flash. GPT-5.5 is used both as a probe of untrained tool usage and as a distillation source in the ablation.
Hyperparameters (all that are reported). Top- for teacher distributions, three distillation epochs, 131,072-token context cap, decoding settings held fixed across all methods. Learning rate, batch size, and optimizer are not stated.
Metrics. Pass@1 accuracy, average tool calls per episode, average peak token count per episode. Pass@4 as a proxy for the capability boundary and (all four independent trials correct) as a consistency measure. Grading uses the simple-evals judge template for both search benchmarks.
Baselines. ReAct (no context management), ReSum and ACON (threshold-triggered summary agents), ACE (cross-task memory playbook). All three are prompting-only, which is why they were chosen. They can be dropped onto the identical Qwen3.5-9B backbone with the same tools and decoding, so any delta is attributable to the mechanism. Mem1, SUPO, and AgentFold are excluded because they require retraining or have unreleased pipelines.
6. Results
6.1 Main table
| Method | BCP Pass@1 | BCP Tools | BCP Peak | DSQA Pass@1 | DSQA Tools | DSQA Peak | SWE Pass@1 | SWE Tools | SWE Peak |
|---|---|---|---|---|---|---|---|---|---|
| Qwen3.5-397B-A17B | 0.653 | 15.6 | 51K | 0.710 | 28.3 | 47K | 0.682 | 58.9 | 38K |
| Gemini3-Flash | 0.733 | 22.9 | 72K | 0.619 | 54.3 | 121K | 0.732 | 66.7 | 80K |
| ReAct (9B) | 0.570 | 19.5 | 63K | 0.367 | 47.4 | 46K | 0.489 | 74.7 | 59K |
| ReSum | 0.608 | 24.7 | 68K | 0.371 | 48.6 | 79K | 0.475 | 75.2 | 61K |
| ACON | 0.614 | 28.2 | 65K | 0.380 | 51.3 | 54K | 0.480 | 76.1 | 57K |
| ACE | 0.589 | 19.8 | 71K | 0.352 | 48.2 | 70K | 0.494 | 75.6 | 65K |
| ACM Base | 0.635 | 30.8 | 59K | 0.405 | 88.7 | 42K | 0.508 | 77.6 | 46K |
| ACM Post-Trained | 0.727 | 46.2 | 54K | 0.425 | 58.8 | 41K | 0.530 | 79.3 | 50K |
Relative gain over ReAct: on BrowseComp-Plus, on DeepSearchQA, on SWE-Bench Verified.
Three things are worth separating.
The framework alone already helps. ACM Base, with no training at all, beats every baseline on all three benchmarks. Agent-initiated compression is doing real work before any distillation.
Post-training roughly triples the gain on search. on BCP. The post-trained 9B model reaches 0.727 against Gemini3-Flash’s 0.733 and beats the 397B model of its own family (0.653), which is about larger. This near-parity is specific to the in-domain benchmark. On DSQA (0.425 vs 0.710) and SWE (0.530 vs 0.732) the frontier gap remains wide.
Out-of-domain transfer is real but smaller. DeepSearchQA is never trained on and uses live web search rather than a fixed corpus, so indicates the learned timing policy is not corpus-specific.
Peak tokens. Against ReAct the reduction is 11% to 15%. The paper’s “around 20%” figure is supported against the summary agents (ReSum on BCP, , is , and on DSQA ) or for ACM Base on SWE (, ). Note that summary agents have higher peak usage than plain ReAct on several cells, exactly as the framework predicts. A threshold trigger by construction lets the context reach the threshold before acting.
Tool calls rise with accuracy. ACM Post-Trained makes 46.2 calls on BCP against ReAct’s 19.5. The interpretation offered is that small models substitute exploration for raw capability, and context management is what makes extended exploration affordable.
6.2 Behavior analysis
Context growth (Figure 3). ACM trajectories show a sawtooth well below the 128K ceiling, with compression points scattered across the whole range rather than clustered near the limit. ReAct trajectories climb monotonically and terminate near turn 60. ACM trajectories run past turn 100.
Tool decomposition (Figure 4), per question on BCP.
| Agent | search | get_document | manage_context | query_memory |
|---|---|---|---|---|
| ACM + GPT-5.5 () | 18.9 | 4.2 | 0.1 | 0.0 |
| ACM + Qwen3.5-9B () | 24.9 | 4.1 | 2.1 | 0.6 |
| ACM Post-Trained () | 28.7 | 6.5 | 6.8 | 1.3 |
The post-trained model leads on every column, not just the memory tools. Compression is not competing with exploration for budget, it is funding it.
Pass@K (Figure 5), BrowseComp-Plus.
| Setting | Pass@4 | Pass@1 | Pass@4 minus | |
|---|---|---|---|---|
| ReAct | 73.5 | 57.0 | 34.1 | 39.4 |
| ACM Agent | 78.8 | 63.5 | 44.0 | 34.8 |
| Post-Trained Ep.1 | 80.0 | 67.7 | 50.7 | 29.3 |
| Post-Trained Ep.2 | 82.0 | 69.8 | 56.0 | 26.0 |
| Post-Trained Ep.3 | 82.0 | 72.7 | 59.3 | 22.7 |
This is the most informative result in the paper. Pass@4 moves points while moves . ACM barely expands the set of solvable problems. What it does is make the solutions reliable. The natural reading is that accumulated context noise is a variance source, and cleaning the working context removes it. Gains are still increasing at epoch 3, with Pass@4 already saturated.
Distillation ablation (Table 3), all on Qwen3.5-9B.
| Config | BCP | DSQA | SWE |
|---|---|---|---|
| Base | 0.635 | 0.405 | 0.508 |
| + GPT-5.5 distill | 0.623 | 0.381 | 0.542 |
| + ACM data | 0.727 | 0.425 | 0.530 |
| + Both | 0.734 | 0.413 | 0.564 |
Generic distillation from a strong teacher actively hurts on search (below the untrained ACM base on both search benchmarks) while helping on coding. ACM data alone is the only configuration that improves everywhere. Combining is best on two of three. The reading offered is that the two signals are complementary, general problem-solving from distillation and timing from ACM data.
Case study (Figure 6), BCP qid 347. A five-constraint multi-hop question (restaurant in the acknowledgments of a UC dissertation, author with a B.Tech from IIT BHU and a UCLA master’s, co-authored papers in 2020 and 2020 to 2022, restaurant founded 1980 to 1988). Gold answer California Pizza Kitchen. The base model fails 0 for 4.
The trajectory illustrates every mechanism at once. At turn 10 the model reports 54,932 tokens and compresses 21 messages into summary_1. At turn 18 it compresses again at 40,982 tokens, explicitly reasoning about approaching half of its budget. At turn 49 a query_memory probe surfaces a lead it then chooses to verify rather than commit to. At turn 58, at 87% usage with 16,606 tokens left, it folds 78 messages whose raw form is 158K into a 2.3K summary. At turns 67 and 79 it confirms two of the five constraints via get_document. At turn 82, sitting at 20,325 tokens, it commits.
Totals: 63 searches, 9 document fetches, 7 compressions, 5 memory queries, 83 turns. Peak actual context 98K against a raw history of 222K. Without compression the trajectory would have crossed the 128K ceiling at turn 47, roughly halfway. The query_memory calls interleaved with manage_context are the direct evidence that the lossless archive is actually being re-read rather than being a write-only sink.
Exploration diversity (Appendix C). Consecutive queries are embedded with Qwen3-Embedding-8B, cosine similarity is computed, and a pivot is declared when . The running pivot fraction is
which is bounded in and converges to the long-run pivot rate regardless of trajectory length. The horizontal axis normalizes token position to so that short ReAct trajectories do not create survivorship bias. Post-trained ACM holds a higher pivot fraction than both ACM and ReAct at all four thresholds . Notably, plain ACM tracks ReAct closely, so the tools alone do not induce exploration. Only the training signal does.
Small models (Appendix D). Qwen3-4B-thinking collapses every BrowseComp-Plus rollout to exactly two turns with 1.2 searches and 3.4% accuracy, against 19.4 turns, 16.2 searches, and 57.3% for the 9B model. On qid 124 the 4B model uses 23K of 131K tokens, explicitly writes that it could do more searches, then in the next sentence hallucinates “since I can’t do real searches, I have to think” and guesses. The failure is a long-horizon planning failure, not a context-budget failure, so the memory tools never get a chance to matter.
7. Limitations
From the paper
- ACM presupposes a base model with strong long-horizon reasoning and tool use.
- No prior context-compression baseline had been evaluated on these three benchmarks. Implementation differences may exist.
AI assessment that I agree
The “lossless” claim overstates what the agent experiences. The raw bytes are preserved, but access runs through a three-step chain: the agent must remember the summary exists, must guess the right summary_id, and the querier LLM must extract the right span. If the summary text drops the pointer that would have made the agent think to query summary 2, the archived content is unreachable in practice. This is recoverable-in-principle, not lossless. A retrieval-recall measurement (how often does the needed fact survive a compress-then-query round trip) is the obvious missing experiment and is absent entirely.
Only when, not how (much). manage_context takes no arguments, so the system picks the compression span. “How much” is decided by the system (everything before the last compression). The abstract’s claim that the agent decides “when and how” is only half true. Also it still leads to growing context because summaries are not cleaned up.
The headline comparison is confounded. ACM Post-Trained is a trained policy. ReSum, ACON, and ACE are prompting-only by explicit design choice. I can do ReSum/ACON/ACE with on policy distillation.
Compute is measured in the wrong currency. Peak tokens is reported. Total tokens is not. Peak token is not about cost.