面向LLM智能体的不变量感知防护机制:防止静默API故障

·

研究论文 · 2026/11/18

LLM代理通过调用API并信任结果来回答问题,但API可能静默失败:忽略请求的一部分(如错误命名的过滤器),却返回HTTP 200和看似合理但错误的结果。现有修复方法(如检查清单、审查模型和LLM评判器)让模型自己捕捉问题,但模型往往看到问题仍照常回答。我们提出SilentGuard,将决策从模型转移到运行工具调用的框架(harness)上。它用任何正确API都必须满足的不变量测试每个结果,并扣留违反不变量的值。我们在15个公共研究API中的11个发现静默失败,计数膨胀高达691倍。现有修复方法导致超过70%的答案错误,代理报告了评判器标记的77.4%的计数。在7个开源模型上,SilentGuard将其目标故障上的错误答案从74.0%降至1.7%,在无故障任务上无损失。在三个前沿模型上,错误答案从70.2%降至0.5%。同一检查的警告仍导致70.1%的错误,因此强制执行是关键。对于新的故障类型,仅框架就将错误答案从61.1%降至24.5%。它通过弃权而非恢复来避免错误答案。

该研究解决了LLM代理因API静默失败而输出错误答案的关键问题,提出了一种有效的框架级强制执行方法,显著降低了错误率,并强调了强制执行优于警告的洞见,对构建可靠的LLM代理系统具有重要实践意义。

LLM agents answer questions by calling APIs and trusting the results. An API can fail silently. It ignores part of a request, such as a misnamed filter, yet returns HTTP 200 and a plausible but wrong result. Current fixes, such as checklists, reviewer models and LLM judges, ask the model to catch it. But models often see the problem and answer anyway. We present SilentGuard, which moves the decision from the model to the harness running tool calls. It tests each result against invariants that any correct API must satisfy and withholds values that break one. We find silent failures in 11 of 15 public research APIs, with counts inflated up to 691 times. Current fixes leave over 70% of answers wrong, and agents report 77.4% of counts a judge flags. Across 7 open models, SilentGuard cuts wrong answers on its target faults from 74.0% to 1.7%, with no loss on fault-free tasks. On three frontier models they fall from 70.2% to 0.5%. A warning from the same check leaves 70.1% wrong, so enforcement is the key. On new fault types, the harness alone cuts wrong answers from 61.1% to 24.5%. It avoids wrong answers by abstaining rather than recovering.

阅读原文

参与讨论