EPS
← All batches·2605.08563

Why Retrying Fails: Context Contamination in LLM Agent Pipelines

topic: general_aitop score: 100released: 2026-05-12first surfaced: 2026-05-12arXivPDFlinked_to_results2026-05-12

Authors: Zhanfu Yang

arXiv · PDF

Summary

The author formalizes why retrying a failed multi-step LLM agent task often doesn't help: the failed attempt stays in the context window and contaminates the next try, raising the per-step error rate above baseline. He introduces a mathematical model (CCRM) with clean error rate ε₀ and contaminated error rate ε₁, derives closed-form success probabilities, optimal budget allocation formulas, and proves that clearing context before retry always helps. Real SWE-bench data shows the contaminated error rate is 7.1× higher than clean, and naive retry models overestimate pass@3 by 17 percentage points.

Main takeaways:

  • Failed tool-call attempts left in context raise subsequent error rates (ε₁ > ε₀), a phenomenon the author calls context contamination
  • Derives exact formulas for success probability, optimal pipeline depth given a retry budget, and the cost of contamination vs. clean restart
  • On SWE-bench Verified, contaminated retries have 7.1× higher error rate than the base rate; naive models overestimate pass@3 by 17.4 pp
  • Proves clearing context before retry yields strictly better success probability
  • Provides information-theoretic lower bounds showing the model is tight

Relevance

Not directly related to my persona or behavioral installation work. This is about agentic retry policies and context contamination in multi-step tool use, not about how behaviors are installed or represented. Could be useful background if I ever build multi-turn agent systems, but no obvious connection to marker implantation or persona geometry.

Abstract

arXiv:2605.08563v1 Announce Type: new Abstract: When an LLM agent fails a multi-step tool-augmented task and retries, the failed attempt typically remains in its context window -- contaminating the next attempt and elevating the per-step error rate beyond the base level. This context-contaminated restart phenomenon is widely observed in practice yet entirely lacks formal treatment. We introduce the Context-Contaminated Restart Model (CCRM): a chain of T tool-call steps, each failing with base rate epsilon_0; after any failed attempt, the subsequent attempt operates in contaminated context with elevated error rate epsilon_1 > epsilon_0. Under this model we derive five main results. (R1) An exact closed-form formula for P(succeed in at most K attempts). (R2) A cascade-overhead theorem giving the additional attempts Delta K incurred by contamination versus the clean-restart baseline. (R3) An optimal budget-allocation theorem identifying the pipeline depth T* that maximises success probability for a fixed total budget B=KT; we prove the closed form T* = sqrt(B * log(1/(1-epsilon_1)) / log(1/(1-epsilon_0))), with K*=B/T*. (R4) An information-theoretic lower bound via Le Cam's method showing K_CCRM is tight up to O(1). (R5) A clean-restart dominance theorem quantifying the exact benefit of context-clearing before retry. We validate CCRM on real SWE-bench Verified data: the IID model overestimates pass@3 by 17.4 percentage points (98.6% vs. 81.2%), while CCRM fits with error less than 0.001, implying a cascade ratio of epsilon_1/epsilon_0 = 7.1. Monte Carlo experiments confirm all theoretical predictions.