Skip to content
Sagan

Paper

Why Retrying Fails: Context Contamination in LLM Agent Pipelines

Unreadunread

AI 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