utils

Chinese-language documentation for a LangChain Classic helper that checks whether an agent's tools accept only one input. LangChain is a framework for building applications that use language models and tools.

In plain words
What is it for?
Use it when building or reviewing LangChain agents, especially when registering tools that may require several values or a structured object.
Why use it?
Some older agents can handle only simple, single-value tool inputs. The check catches incompatible tools early and raises an error before the agent runs.

Agent

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add agents/xt765/langchain-chinese-comment/utils
Clone the repo
git clone --depth 1 https://github.com/xt765/LangChain-Chinese-Comment
Per session 0 Only the description is in the session, so the agent can decide to use it. The body loads when it is invoked.
When invoked 396 The whole file, excluding the scripts and references it only reads on demand.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

What it costs to keep this loaded

Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.

ModelPer sessionOnce invoked
Fable 5 $0.00000 $0.00396
Opus 5 $0.00000 $0.00198
Sonnet 5 $0.00000 $0.00079
Haiku 4.5 $0.00000 $0.00040

Measured 2d ago against content hash 885a74b28039, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

utils scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured 2d ago.

A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.

Nothing flagged

None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.

code_comment/libs/langchain/langchain_classic/agents/utils.md · 36 lines

What it actually says

libs\langchain\langchain_classic\agents\utils.py

此文档提供了 libs\langchain\langchain_classic\agents\utils.py 文件的详细中文注释。该模块包含代理模块中使用的实用工具函数。

功能描述

该模块目前主要负责对代理所使用的工具进行兼容性检查。

核心函数:validate_tools_single_input

该函数用于验证提供给代理的工具列表是否符合“单输入”限制。

1. 背景说明

许多经典的代理(如 ZeroShotAgent)设计时仅能处理简单的字符串输入。如果将需要复杂 JSON 或多个参数的工具分配给这些代理,会导致运行失败。该函数提供了一种前置校验机制。

2. 函数逻辑

def validate_tools_single_input(class_name: str, tools: Sequence[BaseTool]) -> None:
    for tool in tools:
        if not tool.is_single_input:
            msg = f"{class_name} does not support multi-input tool {tool.name}."
            raise ValueError(msg)
  • 参数:
    • class_name: 调用方的类名,用于生成清晰的错误消息。
    • tools: 待检查的工具列表。
  • 行为: 遍历所有工具,若发现任一工具的 is_single_inputFalse,则抛出 ValueError

使用场景

通常在代理类的 from_llm_and_tools__init__ 方法中调用。例如,ZeroShotAgent 会使用它来确保它能正确地将输入传递给工具。

Changes

What this file has done since we first saw it

Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.

  1. 2d ago First seen · 36 lines · 0 tokens per session scan A 885a74b28039

Subscribe to this mod's changes

utils is an agent published in the GitHub repository xt765/LangChain-Chinese-Comment (20 stars, last pushed 1mo ago), licensed MIT. It costs nothing until one of its globs matches a file; then it loads 396 tokens. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-08-30.