返回首页

对比阅读

对比阅读:LangChain Breaks Tool Calling Into Three Steps 与 LangChain 把工具调用拆成三步 — Agent 落地关键不在模型会说什么

AEN
LangChainTool CallingLangGraph·

LangChain Breaks Tool Calling Into Three Steps

LangChain’s Tool mechanism breaks Agent deployment into three explicit steps: the model requests a call, the program executes the function, and the result returns to the model to formulate an answer. Reliable tool use depends not only on model capability, but also on interface descriptions, parameter validation, and permission boundaries.

What This Is

A Tool is a standardized LangChain interface that wraps a Python function so a model can understand and request calls to it. Each tool requires a name, a natural-language description, and a parameter structure, typically expressed with JSON Schema, a structured format for describing fields and their types.

The common approach is to add the @tool decorator to a function, allowing LangChain to extract this information automatically from its signature and docstring. Pydantic provides precise validation when parameters are complex; subclassing BaseTool is better suited to execution logic with special requirements.

The full call chain is not complicated: first, bind_tools sends the tool definitions to the model; the model returns structured tool_calls; the program executes the corresponding function; and the result is sent back under the matching call ID. The model never executes code directly, so permissions and execution responsibility remain on the application side.

Industry View

We see Tool Calling shifting from simply giving models one more action to connecting business systems more reliably. Docstrings and type annotations directly affect call accuracy. This means that when enterprises deploy Agents, the first thing they often need to govern is not the model, but internal interfaces, data permissions, and error handling.

The risks are equally clear: the vaguer a description, the more likely a model is to misuse the tool. When a tool has access to permissions in real systems, incorrect parameters can escalate into erroneous orders, data leaks, or unauthorized operations. Separating user identity, session state, and long-term memory is also essential, but ToolRuntime still cannot replace application-side auditing and authorization. Competitive advantage in this area will therefore depend not just on parameter scale, but on whether the execution layer is controllable, traceable, and recoverable.

Impact on Regular People

For enterprise IT: Traditional systems will gradually expose more interfaces that models can call. IT teams must prepare standardized tool descriptions, access controls, and call logs simultaneously if Agents are to move beyond demos and into everyday workflows.

For individual workers: Assistants will handle more repetitive queries, summaries, and cross-system operations, but final confirmation, accountability, and verification of critical data may still remain with people.

For the consumer market: Customer service, shopping, and software assistants will proactively call real-time services for orders, inventory, and more. Whether these experiences feel reliable will depend on the data quality and exception handling behind those interfaces.

来源: juejin.cn
BZH
LangChainTool CallingLangGraph·

LangChain 把工具调用拆成三步 — Agent 落地关键不在模型会说什么

LangChain 的 Tool 机制把 Agent 落地拆成三个明确步骤:模型提出调用请求,程序执行函数,结果再交给模型组织答案。工具能否可靠工作,关键不只在模型能力,也在接口描述、参数校验和权限边界。

这是什么

Tool 是 LangChain 中把 Python 函数包装成模型可理解、可请求调用的标准化接口。每个工具需要名称、自然语言说明和参数结构;其中参数结构通常用 JSON Schema(描述字段及类型的结构格式)表达。

常见做法是给函数加上 @tool 装饰器,让 LangChain 从函数签名和文档字符串自动读取这些信息。参数复杂时可用 Pydantic 做精细校验;继承 BaseTool 则适合特殊执行逻辑。

完整调用链并不复杂:先通过 bind_tools 把工具说明发给模型,模型返回结构化的 tool_calls,程序执行对应函数,再用匹配的调用编号把结果回传。模型始终不直接运行代码,权限与执行责任仍在应用侧。

行业怎么看

我们注意到,Tool Calling 的价值正在从“让模型多做一步”转向“把业务系统接得更稳”。文档字符串和类型注解会直接影响调用准确率,说明企业部署 Agent 时,最先需要治理的往往不是模型,而是内部接口、数据权限和错误处理。

风险也很明确:描述越模糊,模型越容易误用工具;工具拥有真实系统权限时,错误参数可能放大为错误下单、数据泄露或越权操作。此外,把用户身份、会话状态和长期记忆分开管理很有必要,但 ToolRuntime 仍不能替代应用侧的审计与授权。行业竞争点因此不只是模型参数规模,而是执行层能否做到可控、可追踪、可恢复。

对普通人的影响

对企业 IT:传统系统会逐步增加可被模型调用的接口,IT 团队需要同时准备标准化工具描述、权限控制和调用日志,Agent 才能从演示进入日常流程。

对个人职场:重复查询、汇总与跨系统操作会更多交给助手完成,但最终确认、责任归属和关键数据核验仍可能留在人这一侧。

对消费市场:客服、购物与软件助手会更主动地调用订单、库存等实时服务;体验是否可靠,将取决于这些接口背后的数据质量和异常处理。

来源: juejin.cn