LedgerAgent:用于政策遵循型工具调用代理的结构化状态
LedgerAgent: Structured State for Policy-Adherent Tool-Calling Agents
摘要
在客户服务领域里,负责调用工具的智能代理必须能够在不同交互过程中保持任务状态,同时遵守相关规则。这些任务状态包括用户互动和工具调用过程中所观察到的相关信息、标识符、约束条件等。在传统的智能代理中,这些任务状态并没有被单独表示出来。所有的观察结果、工具返回信息以及规则说明都被包含在提示中,因此智能代理每次决定下一步行动时都需要从提示中重新构建相关状态。这种设计使得状态管理变得隐式,从而产生了两种常见的故障模式:智能代理可能获取到正确的信息,但后续决策却基于过时、缺失或错误的信息;或者,虽然工具调用在语法上是正确的,但它仍然违反了与当前任务状态相关的规则。我们提出了LedgerAgent这一方法,它可以在推理过程中保存所观察到的任务状态,并将这些状态以提示的形式呈现出来。此外,该系统还用于检查与状态相关的规则约束,从而在执行需要改变环境的工具调用之前避免违反规则的情况。在四个不同的客户服务领域以及多种开放性和封闭性模型中,LedgerAgent能够提升平均通过率,尤其是在更严格的多次尝试一致性指标下,其效果最为显著。
English Abstract
Policy-adherent tool-calling agents in customer-service domains must maintain task states across turns while calling tools and obeying domain policies. Task states consist of relevant facts, identifiers, constraints, and conditions observed through user interaction and tool calls. In standard agents, task states are not represented separately. Observations, tool returns, and policy instructions are placed in the prompt, leaving agents to reconstruct the relevant states from the prompt each time they decide what to do next. This design makes state management implicit, creating two common failure modes. An agent may retrieve the right facts but later ground its decision in stale, missing, or incorrect information; and a syntactically valid tool call may still violate a domain policy that depends on the current task state. We introduce LedgerAgent, an inference-time method for tool-calling agents that maintains observed task states in a separate ledger and renders the states into the prompt. The ledger is also used to check state-dependent policy constraints before environment-changing tool calls are executed, blocking policy violations. Across four customer-service domains and a mixed panel of open- and closed-weight models, LedgerAgent improves average passk over a standard prompt-based tool-calling approach, with the largest gains under stricter multi-trial consistency metrics.