langchain-agents
Create and use LangChain agents with createAgent - includes agent loops, ReAct pattern, tool execution, and state management
npx skills add majiayu000/claude-skill-registry --skill langchain-agents-evanfang0054-cc-system-creator-sc --agent claude-code
Same command for any agent — swap --agent for codex, cursor, copilot.
Weekly change comes from our own snapshots, not the repository page — it measures attention, not adoption.
# langchain-agents (JavaScript/TypeScript) ## 概述 代理(Agents)结合语言模型和工具来创建可以推理任务、决定使用哪些工具并迭代地朝着解决方案工作的系统。`createAgent()` 函数提供了基于 LangGraph 构建的生产就绪的代理实现。 **核心概念:** - **代理循环(Agent Loop)**:模型决定 → 调用工具 → 观察结果 → 重复直到完成 - **ReAct 模式**:推理和行动(Reasoning and Acting)- 代理推理要做什么,然后通过调用工具来行动 - **基于图的运行时**:代理在具有节点(模型、工具、中间件)和边的 LangGraph 图上运行 ## 何时使用代理 | 场景 | 使用代理? | 原因 | |----------|-----------|-----| | 需要调用外部 API/数据库 | ✅ 是 | 代理可以动态选择调用哪些工具 | | 有决策点的多步骤任务 | ✅ 是 | 代理循环处理迭代推理 | | 简单的提示-响应 | ❌ 否 | 直接使用聊天模型 | | 预定义的工作流 | ❌ 否 | 改用 LangGraph 工作流 | | 需要工具调用但不迭代 | ⚠️ 可能 | 考虑直接使用 model.bindTools() | ## 决策表 ### 选择代理配置 | 需求 | 配置 | 示例 | |------|---------------|---------| | 带工具的基本代理 | `createAgent({ model, tools })` | 搜索、计算器、天气 | | 自定义系统指令 | 添加 `systemPrompt` | 特定领域的行为 | | 敏感操作的人工批准 | 添加 `humanInTheLoopMiddleware` | 数据库写入、电子邮件 | | 跨会话持久化 | 添加 `checkpointer` | 多轮对话 | | 结构化输出格式 | 添加 `responseFormat` | 提取联系信息、解析表单 | ### 工具策略 | 工具类型 | 何时使用 | 示例 | |-----------|-------------|---------| | 静态工具 | 工具在执行期间不变 | 搜索、天气、计算器 | | 动态工具 | 工具依赖于运行时状态 | 用户特定的 API | | 内置工具 | 需要常用功能 | 文件系统、代码执行 | | 自定义工具 | 特定于领域的操作 | 您的业务逻辑 | ## 代码示例 ### 带工具的基本代理 ```typescript import { createAgent } from "langchain"; import { tool } from "langchain"
- 概述
- 何时使用代理
- 决策表
- 选择代理配置
- 工具策略
- 代码示例
- 带工具的基本代理
- 带系统提示的代理
- 代理循环执行流程
- 流式传输代理进度
- 带持久化的代理
- 并行调用多个工具
- 动态工具(依赖于运行时)
- 代理中的错误处理
What does the langchain-agents skill do?
Create and use LangChain agents with createAgent - includes agent loops, ReAct pattern, tool execution, and state management
How do I install it?
Run `npx skills add majiayu000/claude-skill-registry --skill langchain-agents-evanfang0054-cc-system-creator-sc --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.
