为何重试失效:LLM代理流水线中的上下文污染
Why Retrying Fails: Context Contamination in LLM Agent Pipelines
AI总结:
本文研究LLM代理在多步骤工具增强任务中重试失败的上下文污染问题,提出上下文污染重试模型(CCRM),推导了五个核心结果,包括成功概率公式、重试开销定理、预算分配定理等,并通过实验证明模型的有效性。
摘要:
当LLM代理在多步骤工具增强任务中失败并重试时,失败的尝试通常保留在其上下文窗口中——污染后续尝试并使每一步的错误率超过基础水平。这种被污染的重试现象在实践中广泛存在,但缺乏正式处理。我们引入上下文污染重试模型(CCRM):一个包含T个工具调用步骤的链式结构,每个步骤以基础错误率epsilon_0失败;在任何失败尝试后,后续尝试在被污染的上下文中以更高的错误率epsilon_1>epsilon_0运行。在该模型下,我们推导了五个主要结果。 (R1) 一个精确的闭式公式,用于计算最多K次尝试中成功的概率。 (R2) 一个重试开销定理,说明污染与干净重试基线相比所增加的尝试次数Delta K。 (R3) 一个最优预算分配定理,确定在固定总预算B=KT下最大化成功概率的流水线深度T*,我们证明T* = sqrt(B * log(1/(1-epsilon_1)) / log(1/(1-epsilon_0))),其中K*=B/T*。 (R4) 一个通过Le Cam方法得到的信息论下界,显示K_CCRM在O(1)范围内是紧的。 (R5) 一个干净重试主导定理,量化了在重试前清除上下文的精确好处。我们通过真实SWE-bench Verified数据验证了CCRM:IID模型高估了pass@3的17.4个百分点(98.6% vs. 81.2%),而CCRM的误差小于0.001,表明级联比率为epsilon_1/epsilon_0=7.1。蒙特卡洛实验验证了所有理论预测。
英文摘要:
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.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。