arXiv:2606.07904cs.AIcs.SE2026-06被引 4

让大模型自动学会工具使用条件和效果,提升任务可靠性。

Contract2Tool: Learning Preconditions and Effects for Reliable Tool-Augmented LLM Agents

  • 从文档和调用记录中自动推导工具使用条件与影响
  • 学习到的合约使任务成功率达0.980,接近人工合约的0.990
  • 适合需要高效可靠工具调用的智能代理开发场景

增强型大语言模型代理越来越多依赖外部API,但标准工具接口仅说明如何调用,未定义何时适用或产生何种任务状态。因果工具过滤通过轻量级合约明确每个工具的前置条件、作用、风险等级和成本来填补这一空白。然而,手动编写和维护合约难以适应大规模或动态变化的工具生态。本文提出Contract2Tool框架,通过元数据、接口定义、文档和执行日志推导工具合约。该框架将可观测的工具证据转化为标准化符号合约,可内在评估并部署于下游因果工具过滤中。在真实任务中,对比金标准前提、效果和风险标签,验证学习合约的准确性;同时评估其在多步任务中的实用性。结果表明,结合文档与调用痕迹的混合证据可生成足够精确的合约,保留金合约绝大部分可靠性与效率优势:学习合约的因果工具过滤(CMTF)下游成功率达0.980,接近金合约的0.990;可见工具数从100降至1,平均令牌消耗从26,172降至2,528,显著优于全工具暴露。结果表明,学习合约可作为工具接口与可靠代理执行之间的可扩展合约层。

原文摘要 · Abstract (English)

Tool-augmented large language model agents increasingly rely on external APIs, but standard tool schemas describe how to call a tool, not when the tool is causally appropriate or what task state it produces. Causal tool filtering addresses this gap by using lightweight contracts that specify each tool's preconditions, effects, risk level, and cost. However, manually writing and maintaining such contracts does not scale to large or changing tool ecosystems. We introduce Contract2Tool, a framework for inferring tool contracts from metadata, schemas, documentation, and execution traces. Contract2Tool converts observable tool evidence into normalized symbolic contracts that can be evaluated intrinsically and deployed inside downstream causal tool filtering. We evaluate learned contracts against gold preconditions, effects, and risk labels, and measure their downstream utility on multi-step agent tasks. Our results show that hybrid documentation-and-trace evidence produces contracts accurate enough to preserve most of the reliability and efficiency benefits of gold contracts. Learned-contract CMTF achieves 0.980 downstream success, close to 0.990 for gold-contract CMTF, while reducing visible tools from 100 to 1 and reducing average token usage from 26,172 to 2,528 relative to all-tools exposure. These results suggest that learned contracts can provide a scalable contract layer between tool schemas and reliable agent execution.

智能代理工具调用自动化合约可靠性

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。