Full text not available for this paper
Summary (Overview)
- This paper introduces a quality-gated physical-accounting protocol for evaluating coding agents, measuring not just prompt tokens but also uncached prefill, KV cache residency, wall time, and GPU energy.
- The authors decompose executed prefill into logical prompt tokens minus reused prefix tokens (Equation 1), showing that token savings can paradoxically increase physical work when prefix reuse is lost.
- On 450 localization cases from SWE-rebench V2, both EAGER (preloading ten retrieved blocks) and COMPACT (anchored history compaction) pass a five-point non-inferiority quality gate.
- EAGER reduces model calls by 35.7% and GPU-energy proxy by 33.2% versus on-demand search (GREP), while COMPACT adds no further savings.
- MASK-5 (keeping only five observations) cuts prompt volume by 33.3% but increases uncached prefill by 608.5% and energy by 125.6%, failing the quality gate—demonstrating that editing reusable history can multiply physical work.
Introduction and Theoretical Foundation
Background and Motivation
Repository localization maps an issue report to files, classes, and functions. Modern coding agents use iterative retrieval, structure-aware search, and graph navigation within ReAct-style loops. These agents repeatedly search, read, and reassess retrieved source code, creating long trajectories of tool outputs and intermediate hypotheses.
The core problem: token counts do not determine physical cost. Serving runtimes like vLLM and SGLang maintain KV caches; when a new request begins with a cached token prefix, the runtime reuses those entries and prefills only the remaining suffix. A shorter prompt can therefore cost more if it rewrites cached history, forcing recomputation of all subsequent tokens.
Theoretical Foundation
The paper formalizes the relationship between logical and executed work. Let be the number of model requests under policy , the logical prompt tokens in request , and the tokens served from a reusable prefix. Then:
For a treatment–control contrast:
Key insight: Prompt savings increase executed prefill when a policy loses more reusable tokens than it removes. Because also depends on the policy, fewer calls can reduce total work even when each call is no cheaper.
Three Research Challenges
- C1 (Trajectory attribution): Evidence supply, delivery time, and history retention can each change what the agent does next.
- C2 (Logical-to-physical translation): A policy changes both request count and prefix reuse; logical tokens can order policies differently from uncached prefill, KV occupancy, latency, or energy.
- C3 (Quality-constrained comparison): Resource comparisons must first bound task-quality loss.
Methodology
Experimental Setup
The study uses an NVIDIA DGX Spark with an NVIDIA GB10 SoC and 128 GB coherent unified memory. The localization stack uses Qwen3.6-35B-A3B-FP8 (35B total, 3B active) with vLLM, temperature zero, and 65,536-token context limit.
Policy Algebra
Let identify the agent scaffold, its system prompt, and its canonical action–observation history. An experimental arm is where is the evidence supplied before the first turn and controls visible serialization. The visible state and serialized model input are:
where denotes serialization.
Three deterministic context-serialization operators:
Here is the first successful source read, is a scaffold-specific anchor containing the task query, the successful read, and a bounded pre-rewrite assessment. follows SWE-agent's LastNObservations: it keeps actions and tool IDs but replaces older outputs with line-count markers .
The arm definitions:
Quality-Constrained Resource Objective
The resource vector collected for each policy:
where is the KV time-area (integrated KV bytes over wall time, in GiB·s), is peak KV occupancy, is peak unified-memory pressure, and is sampled GPU energy.
A policy is eligible only if:
where LCB is the lower endpoint of a paired 95% interval obtained by resampling whole repositories, and is the task-quality endpoint.
Datasets
| Cohort | Source | Size | Purpose |
|---|---|---|---|
| Resource cohort | codenib-synthesis test split | 100 tasks × 3 reps = 900 cells | Repeated device measurement |
| Quality cohort | SWE-rebench V2 | 450 Python issues | Quality gate (powered) |
| Cache mechanism study | Same 100 tasks | 600 cells | Prefix-cache intervention |
| External patch study | SWE-bench Verified | 100 instances | Cross-scaffold validation |
Empirical Validation / Results
RQ1: Quality-Eligible Policies and Shorter Trajectories
Across 450 localization cases, the frozen retriever reaches .431 Recall@5 and .548 Recall@10. Agent Recall@5 is .470, .478, and .494 for GREP, EAGER, and COMPACT respectively.
- EAGER: paired difference +0.8 points; lower 95% endpoint −2.6 (clears the −5-point gate)
- COMPACT: paired difference +2.4 points; lower endpoint −0.9 (meets the criterion)
Table 1: Localization-only profile for
| Metric | GREP | EAGER | COMPACT |
|---|---|---|---|
| Task quality | |||
| Recall@5 | .470 | .478 | .494 |
| Full@5 | .307 | .318 | .329 |
| Format success | .904 | .976 | .987 |
| Resource per attempted task | |||
| Prompt ktok | 136.8 | 90.5 (−33.9%) | 98.2 (−28.2%) |
| Successful server calls | 13.02 | 8.38 (−35.7%) | 9.49 (−27.1%) |
| Wall seconds | 68.32 | 48.22 (−29.4%) | 52.20 (−23.6%) |
| KV GiB·s | 25.88 | 16.67 (−35.6%) | 18.21 (−29.6%) |
| GPU-proxy kJ | 2.007 | 1.340 (−33.2%) | 1.466 (−27.0%) |
| Resource per full-recall | |||
| Prompt ktok/full | 204.2 | 133.7 (−34.5%) | 151.9 (−25.6%) |
| GPU-proxy kJ/full | 3.00 | 1.98 (−34.0%) | 2.27 (−24.3%) |
Key finding: COMPACT uses 8.5% more prompt tokens, 13.3% more calls, 8.2% more wall time, and 9.4% more energy than EAGER. The anchor drops remaining candidates, and the agent may search again for evidence that EAGER still shows.
RQ2: Physical Savings Follow Fewer Calls
For all four primary cost metrics, intervals for both policies exclude zero. Mean TTFT varies by less than 2%, and latency per successful call rises from 5.218 to 5.721 seconds (EAGER) and 5.468 (COMPACT), so task-time savings come from fewer calls, not faster calls.
Cache intervention results (600 cells, toggling vLLM prefix-cache flag):
- EAGER's logical prompt changes by +8.3% (95% CI [−5.7, +24.7]) but uncached prefill by −67.7% ([−71.0, −63.8])
- The planned cache interaction is −7.1k uncached tokens per task; 95% interval [−17.3k, +2.3k] (includes zero)
RQ3: Token Savings Reverse under External Retention
Table 2: Patch-generation-only profile for : mini-SWE-agent on 100 SWE-bench Verified instances
| Metric | MINI | EAGER | COMPACT | MASK-5 |
|---|---|---|---|---|
| Task outcome (of 100) | ||||
| Resolved | 30 | 29 | 30 | 26 |
| Submitted / call-capped | 45/55 | 44/56 | 45/55 | 40/60 |
| Generation resource per attempt | ||||
| Prompt ktok | 220.7 | 225.6 (+2.2%) | 210.8 (−6.5%) | 150.5 (−33.3%) |
| Model calls | 26.13 | 25.66 (−1.8%) | 25.84 (+0.7%) | 26.33 (+2.6%) |
| Uncached ktok | 9.8 | 10.0 (+1.4%) | 12.2 (+22.0%) | 70.8 (+608.5%) |
| KV frac.·s | 2.94 | 3.25 (+10.6%) | 2.69 (−17.2%) | 3.55 (+9.4%) |
| Wall seconds | 120.2 | 122.7 (+2.0%) | 116.6 (−5.0%) | 167.9 (+36.9%) |
| GPU-proxy kJ | 1.833 | 1.956 (+6.7%) | 1.917 (−2.0%) | 4.412 (+125.6%) |
Critical finding: MASK-5 removes 75.1k logical prompt tokens per attempt but loses 135.9k device-hit tokens, adding 60.8k uncached tokens. Cached prefixes serve about 96% of EAGER's prompt but only 53% of MASK-5's. The paired quality difference is −3.0 points with lower 95% endpoint −8.6, crossing the −5-point gate and thus failing non-inferiority.
Theoretical and Practical Implications
Break-Even Analysis for History Deletion
The paper derives a first-order estimate: if a runtime served a fraction of the hits observed here in both arms, masking would change uncached prefill by:
This turns positive above . At (no prefix cache), masking would save prefill; batching or cache pressure that evicts prefixes lowers and with it the masking penalty.
Three Key Recommendations
-
Separate evidence delivery from retention (C1): Eager uses the fewest resources among eligible localization arms; the anchor remains eligible but adds no saving because shorter requests don't offset additional calls.
-
Measure prefix reuse (C2): Reports should expose request count, prefix reuse, and uncached prefill alongside prompt volume.
-
Constrain quality before comparing resources (C3): Apply Equation (6) before interpreting resource differences. Token count alone would favor the policy that the quality gate excludes.
Conclusion
A context policy changes both what an agent does and how much of its prompt the runtime can reuse. The paper demonstrates that:
- Early evidence (EAGER) saved work by avoiding calls, reducing model calls by 35.7% and GPU energy by 33.2%.
- Repeated observation masking (MASK-5) turned a 33.3% prompt saving into a 608.5% rise in uncached prefill and a 125.6% energy increase, while failing the quality gate.
- Resource comparisons should measure executed work (uncached prefill, KV time-area, energy) and admit only policies that pass a quality gate.
Limitations and Future Directions
- Results cover two stacks on one DGX Spark serving one request at a time; batching, cache pressure, and cloud GPUs remain untested.
- The GPU-energy proxy omits CPU, host-memory, and whole-system energy.
- Only four fixed policies were tested; window sweeps, LLM summarization, learned pruning, and external memory remain unmeasured, though Equation (1) applies to each.
- The 32-call patch cap measures fixed-budget performance, not unrestricted SWE-bench ability.
Related papers
- Beyond the Training Horizon: Mechanisms and Limits of Length Generalization in Looped Transformers
Looped Transformers achieve length generalization via distinct recurrent mechanisms, but success does not guarantee faithful step-by-step reasoning when tasks permit lossy shortcuts.
- Self-Evolving Agents Can Repair Failures but Struggle to Generalize from Them
Self-evolving LLM agents repair previously failed tasks from failure-derived experience but consistently fail to generalize these gains to unseen tasks, revealing a fundamental repair–generalization gap.
- Internalizing Chain-of-thought into Looped Transformers
Looped transformers can simulate Turing machines with both context window and chain-of-thought length reduced by a factor L, trading external tokens for internal recurrent computation.