用因果分析定位大模型任务失败根源,自动生成最小修复方案。
CausalFlow: Causal Attribution and Counterfactual Repair for LLM Agent Failures
- 通过反事实干预计算每步责任分,定位导致失败的关键步骤。
- 生成最小修改修复方案,使失败任务转为成功,验证率超90%。
- 适合提升复杂任务中大模型的可靠性,尤其适用于医疗和代码场景。
大型语言模型代理在涉及推理、工具使用和环境交互的多步任务中频繁失败。尽管这些失败通常仅被记录或通过启发式方法重试,但其执行日志中蕴含着结构化信号,可揭示执行中断的位置。我们提出CausalFlow,一种干预式框架,将失败的代理轨迹转化为最小反事实修复与可复用的监督信号。CausalFlow将执行轨迹建模为依赖步骤的序列,通过步骤级反事实干预计算因果责任分数(CRS),以识别引发失败的步骤。针对这些步骤,生成仅轻微修改即可使结果转为成功的修复方案,形成经验证的对比对:(错误步骤, 修正步骤)。该框架支持两种互补用途:一是测试时的定向修复,实现最小行为偏移下的失败恢复;二是训练时的监督信号,适用于离线偏好优化或奖励建模。在涵盖数学推理、代码生成、问答和医疗浏览的四个基准上,CausalFlow将失败执行转化为高最小性与因果一致性得分的验证修复,证明因果归因对于跨多样化任务的可靠改进至关重要,在复杂检索场景中优于启发式修正,并始终产生更局部化的修复。结果表明,对结构化执行轨迹进行干预分析,可提供一种原则性强且可扩展的方法,将代理失败转化为可靠性提升与学习就绪的监督信号。
原文摘要 · Abstract (English)
Large language model (LLM) agents frequently fail on multi-step tasks involving reasoning, tool use, and environment interaction. While such failures are typically logged or retried heuristically, they contain structured signals about where execution broke down. We introduce CausalFlow, an interventional framework that converts failed agent traces into minimal counterfactual repairs and reusable supervision. CausalFlow models execution traces as sequential chains of dependent steps and computes Causal Responsibility Scores(CRS) via step-level counterfactual intervention to identify failure-inducing steps. For these steps, we generate minimally edited repairs that flip the final outcome to success, producing validated contrastive pairs of the form (wrong step, corrected step). CausalFlow supports two complementary uses: targeted test-time repair that recovers from failures with minimal behavioral drift, and training-time supervision suitable for offline preference optimization or reward modeling. Across four benchmarks spanning mathematical reasoning, code generation, question answering, and medical browsing, CausalFlow converts failed executions into validated minimal repairs with high minimality and causal-consensus scores, and demonstrates that causal attribution is necessary for reliable improvement across diverse agent tasks, outperforming heuristic refinement in complex retrieval settings while producing more localized repairs throughout. These results demonstrate that interventional analysis over structured execution traces provides a principled and scalable mechanism for transforming agent failures into reliability gains and learning-ready supervision.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。