Agent skill

langchain-tool-calling

聊天模型如何调用工具 - 包括 bindTools、工具选择策略、并行工具调用和工具消息处理

majiayu000github.com/majiayu000GitHub ↗
claude-codeMIT
Install
npx skills add majiayu000/claude-skill-registry --skill langchain-tool-calling --agent claude-code

Same command for any agent — swap --agent for codex, cursor, copilot.

Facts
Files in the skill folder: 2
SKILL.md size: 10 KB
Bundled scripts: none
Path: skills/ai-llm/langchain-tool-calling/SKILL.md
Open the folder on GitHub →
Where it comes from
Stars: 534
Language: HTML

Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.

From the SKILL.md

# langchain-tool-calling (JavaScript/TypeScript) ## 概述 工具调用允许聊天模型请求执行外部函数。模型根据用户输入决定调用哪些工具,然后将结果传回模型以进行进一步推理。这是代理行为的基础。 **核心概念:** - **bindTools()**:将工具绑定到模型 - **工具调用**:模型请求执行工具(在 AIMessage.tool_calls 中) - **工具消息**:传回模型的结果(ToolMessage) - **工具选择**:控制模型可以使用的工具 ## 何时使用工具调用 | 场景 | 使用工具调用? | 原因 | |----------|------------------|------| | 需要外部数据(API、数据库) | ✅ 是 | 模型无法直接访问外部数据 | | 带操作的多步推理 | ✅ 是 | 模型根据结果决定下一步操作 | | 简单问答 | ❌ 否 | 不需要工具 | | 预定工作流 | ⚠️ 可能 | 考虑模型是否需要决定步骤 | ## 决策表 ### 工具选择策略 | 策略 | 使用时机 | 示例 | |----------|-------------|---------| | `"auto"`(默认) | 模型决定是否/使用哪个工具 | 通用目的 | | `"any"` | 强制模型使用至少一个工具 | 提取、分类 | | `"tool_name"` | 强制特定工具 | 当您知道需要哪个工具时 | | `"none"` | 防止工具使用 | 工具执行后 | ### 处理工具调用 | 模式 | 使用时机 | 示例 | |---------|-------------|---------| | 手动执行 | 代理外部 | 测试、自定义工作流 | | 代理循环 | 生产使用 | createAgent 自动处理 | | 并行执行 | 多个独立工具 | 天气 + 新闻查询 | ## 代码示例 ### 基本工具调用 ```typescript import { ChatOpenAI } from "@langchain/openai"; import { tool } from "langchain"; import { z } from "zod"; // 定义工具 const getWeather = tool( async ({ location }: { location: string }) => { return `${location}的天气:晴天,72°F`; }, { name: "get_weather", description: "获取位置的当前天气", schema: z.object({ location: z.string().describe("城市

What's inside
Steps it walks through
  1. 概述
  2. 何时使用工具调用
  3. 决策表
  4. 工具选择策略
  5. 处理工具调用
  6. 代码示例
  7. 基本工具调用
  8. 手动执行工具调用
  9. 工具选择:强制工具使用
  10. 工具选择:强制任意工具
  11. 并行工具调用
  12. 工具消息结构
  13. 处理工具错误
  14. 提供商特定的内置工具
Ships with 1 file
  • metadata.json
More from claude-skill-registry
All skills →
About this skill
What does the langchain-tool-calling skill do?

聊天模型如何调用工具 - 包括 bindTools、工具选择策略、并行工具调用和工具消息处理

How do I install it?

Run `npx skills add majiayu000/claude-skill-registry --skill langchain-tool-calling --agent claude-code` — it drops the skill into your project so the agent can pick it up. Swap the --agent value for codex, cursor or copilot if you use one of those.

Where does this skill come from?

From majiayu000/claude-skill-registry, a repository with 534 stars. We read it straight from the repository tree rather than a submitted listing, so what you see here is what is actually published.

Is a popular skill a good skill?

Not necessarily. Stars measure attention, not adoption — a repository can trend for a week and be abandoned. That is why we show the weekly change from our own snapshots next to the total, instead of a single flattering number.

Keep going