Length-Constrained Experience Pruning for Long-Context Robustness in Prompt Optimization
Enforce explicit token budgets during context engineering by scoring and pruning experience tokens to eliminate context rot while preserving key problem-solving heuristics.
Time
Compute level
Resources
What the paper used
Prerequisites
Scope
The Gap
Appendix F (Figure 18 and Table 6) demonstrates context rot: when in-context experiences grow from 3,859 tokens (1 demonstration) to 11,112 tokens (3 demonstrations), model accuracy drops drastically from 68.50% to 26.50% on MATH500. Accumulating raw experiences or verbose bullet points in LCE playbooks inflates prompt length, which degrades model focus and leads to failure.
“Length alone is therefore sufficient to drive performance below baseline. Together with the gold ICL result, this shows that the value of an injected experience is not monotonic in either quality or quantity”
Limitation
Unbounded context accumulation in LCEs leads to length-induced performance degradation (context rot), where extended prompts distract the model from critical reasoning steps.
Proposed Solution
Introduce an information-theoretic context budget manager into the consolidation phase (phi) of LCE methods. Implement trajectory token attribution scoring (using gradient-free attention masking or perplexity impact) to rank experience tokens. Prune redundant background text, repetitive examples, and low-impact guidelines to maintain total prompt length strictly below a parameterized budget (e.g., 2,000 tokens) while maximizing information density.
The paper’s authors list this direction as future work, so they may already be pursuing it.
Why This Matters
Mitigating context rot ensures that context engineering methods remain scalable over hundreds of task trials without degrading inference speed or reasoning accuracy.
How to Get Started
How to test it: Test length-constrained experience pruning against baseline unconstrained ACE and TF-GRPO on MATH500 and HotpotQA across prompt budgets (1k, 2k, 4k tokens). Metric: test set accuracy and prompt token count. Stop project if pruned contexts perform worse than simple concise CoT prompts.
- Reproduce the context length ablation experiment (Figure 18) in LCEBench using MATH500.
- Develop an automated experience token scorer using localized LLM surprise / perplexity reduction metrics.
- Implement a greedy token-budget selection algorithm inside the ACE curator module.
- Evaluate model accuracy across different hard token limits (500, 1000, 2000 tokens).
Code linked to this paper on Hugging Face: github.com/costa-nus/LCEBench
Suggested by AI. Adapt it to your setup.
Has This Been Done?
Papers like Shapley Context Pruning and SWE-Pruner explore context reranking, token attribution, and self-adaptive context pruning for agents. However, none specifically combine an information-theoretic budget manager with token attribution scoring during the consolidation phase of LCE methods to strictly limit prompt lengths.
- Shapley Context Pruning: A Cooperative Game Perspective for Context Reranking and Pruning · 2026 · 1 citations
- SWE-Pruner: Self-Adaptive Context Pruning for Coding Agents · 2026 · 79 citations
We searched OpenAlex and arXiv for “context rot length constrained prompt optimization LLM experience pruning in context compression” and “Length-Constrained Experience Pruning for Long-Context Robustness in Prompt Optimization” and an AI compared the idea with the top 10 results. A small search can miss relevant work.
Source Paper
Revisiting LLMs as Context EngineersJunrui Zhang, Zeyu Xu, Runchuan Zhu +7 more · 2026
This paper presents a systematic benchmark evaluating Large Language Model as Context Engineer (LCE) approaches across diverse reasoning tasks and open-weight model families. The authors find that existing LCE methods do not consistently outperform standard Chain-of-Thought or In-Context Learning baselines, and their effectiveness is bottlenecked by model inability to distill unified principles from highly diverse failure modes.
Related Ideas
- Semantic Compressive Memory for Long-Horizon ContextMiroThinker: Pushing the Performance Boundaries of Open-Source Research Agents via Model, Context, and Interactive Scaling🟠Medium
- Dynamic Context Summarization for Long-Running TasksAutoDev: Automated AI-Driven Development🟡Fairly easy
- Visual Token Compression for Extended Context HistoryFara-7B: An Efficient Agentic Model for Computer Use🔴Hard
- Importance-Weighted Semantic Memory Compaction for Ultra-Long Horizon TasksGamer: A Generalist Vision-Language-Action Foundation Model for Long-Horizon Real-Time Game Agent🟡Fairly easy
- Long-Context Hierarchical Heads and Retrieval Wrappers for Fixed-Length Pretrained ModelsHuggingFace's Transformers: State-of-the-art Natural Language Processing🟡Fairly easy