CodeTracer可追踪代码智能体状态变化,定位错误源头。
CodeTracer: Towards Traceable Agent States

- 通过动态解析运行日志,构建分层状态追踪树。
- 在4个主流框架上测试,错误定位准确率显著提升。
- 适合需要调试复杂代码智能体的开发者和研究者。
代码智能体发展迅速,但调试难度日益增加。随着框架协调并行工具调用和多阶段工作流处理复杂任务,智能体的状态转换与错误传播难以观察。早期失误可能导致智能体陷入无效循环或引发根本性错误,形成隐藏的错误链,难以判断何时偏离轨道及原因。现有分析方法或局限于简单交互,或依赖小规模人工检查,难以扩展至真实编码流程。我们提出CodeTracer,一种追踪架构:通过不断演化的提取器解析异构运行产物,以持久化内存重建完整的状态转移历史为层次化追踪树,并实现故障起始点定位,精准识别故障源头及其下游影响链。为支持系统评估,我们基于四个广泛使用的代码智能体框架,在多样化代码任务(如修复漏洞、重构代码、终端交互)上生成大量执行轨迹,构建了CodeTraceBench数据集,提供阶段与步骤级标注用于故障定位。实验表明,CodeTracer显著优于直接提示和轻量基线,且重放其诊断信号可在相同预算下稳定恢复原失败运行。代码与数据已公开。
原文摘要 · Abstract (English)
Code agents are advancing rapidly, but debugging them is becoming increasingly difficult. As frameworks orchestrate parallel tool calls and multi-stage workflows over complex tasks, making the agent's state transitions and error propagation hard to observe. In these runs, an early misstep can trap the agent in unproductive loops or even cascade into fundamental errors, forming hidden error chains that make it hard to tell when the agent goes off track and why. Existing agent tracing analyses either focus on simple interaction or rely on small-scale manual inspection, which limits their scalability and usefulness for real coding workflows. We present CodeTracer, a tracing architecture that parses heterogeneous run artifacts through evolving extractors, reconstructs the full state transition history as a hierarchical trace tree with persistent memory, and performs failure onset localization to pinpoint the failure origin and its downstream chain. To enable systematic evaluation, we construct CodeTraceBench from a large collection of executed trajectories generated by four widely used code agent frameworks on diverse code tasks (e.g., bug fixing, refactoring, and terminal interaction), with supervision at both the stage and step levels for failure localization. Experiments show that CodeTracer substantially outperforms direct prompting and lightweight baselines, and that replaying its diagnostic signals consistently recovers originally failed runs under matched budgets. Our code and data are publicly available.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。