基于大语言模型的多智能体系统正越来越多地被部署在长周期任务上,但一个关键性错误往往会被下游智能体接受,并级联成整个轨迹层面的失败。现有研究将此问题框架化为*事后失败归因*,即在轨迹结束后诊断出有责任的智能体和步骤。然而,这种范式放弃了在轨迹仍在进行时进行干预的任何机会。在这项工作中,我们引入了 AgentForesight,这是一个将问题重新定义为在线审计的框架:在一条正在展开的轨迹的每一步,审计者仅观察当前的前缀,并且必须在无法访问未来步骤的情况下,要么继续运行,要么在最早的关键性错误处发出警报。为此,我们整理了 AFTraj-2K,一个涵盖编程、数学和智能体领域的智能体轨迹语料库,其中安全轨迹在严格的整理流程下被保留,不安全轨迹则通过多位大语言模型评判者达成共识,在其关键性错误步骤处进行标注。在此基础上,我们开发了 AgentForesight-7B,一个紧凑的在线审计者,通过一种由粗到细的强化学习方案进行训练:该方案首先在相邻安全/不安全前缀对的失败边界上为其配备风险预期先验,然后在一个三轴奖励(分别针对审计结论的“什么”、“哪里”和“谁”)下,将该先验锐化为精确的步骤级定位。在 AFTraj-2K 和一个外部 Who&When 基准测试上,AgentForesight-7B 超越了包括 GPT-4.1 和 DeepSeek-V4-Pro 在内的领先专有模型,实现了高达 +19.9% 的性能提升和 3 倍的步骤定位误差降低,从而将事后失败检测的闭环转变为支持部署时干预。项目页面:https://zbox1005.github.io/agent-foresight/
LLM-based multi-agent systems are increasingly deployed on long-horizon tasks, but a single decisive error is often accepted by downstream agents and cascades into trajectory-level failure. Existing work frames this as \emph{post-hoc failure attribution}, diagnosing the responsible agent and step after the trajectory has ended. However, this paradigm forfeits any opportunity to intervene while trajectory is still unfolding. In this work, we introduce AgentForesight, a framework that reframes this problem as online auditing: at each step of an unfolding trajectory, an auditor observes only the current prefix and must either continue the run or alarm at the earliest decisive error, without access to future steps. To this end, we curate AFTraj-2K, a corpus of agentic trajectories across Coding, Math, and Agentic domains, in which safe trajectories are retained under a strict curation pipeline and unsafe trajectories are annotated at the step of their decisive error via consensus among multiple LLM judges. Built on that, we develop AgentForesight-7B, a compact online auditor trained with a coarse-to-fine reinforcement learning recipe that first equips it with a risk-anticipation prior at the failure boundary on adjacent safe/unsafe prefix pairs, then sharpens this prior into precise step-level localization under a three-axis reward jointly targeting the what, where, and who of an audit verdict. Across AFTraj-2K and an external Who&When benchmark, AgentForesight-7B outperforms leading proprietary models, including GPT-4.1 and DeepSeek-V4-Pro, achieving up to +19.9% performance gain and 3$\times$ lower step localization error, opening the loop from post-hoc failures detection to enabling deployment-time intervention. Project page: https://zbox1005.github.io/agent-foresight/