LangChain 助手
- 作者仓库星标 0
- 作者更新于 实时读取
- 作者仓库 skills-registry
- 领域
- AI 智能
- 兼容 Agent
-
- Claude Code
- Cursor
- Cline
- Codex
- Windsurf
- Gemini CLI
- +20
- 信任分
- 88 / 100 · 社区维护
- 作者 / 版本 / 许可
- @tomevault-io · 未声明 license
- Token 消耗评级
- 低消耗
- 接入复杂程度
- 需简单配置
- 是否需要外部 API Key
- 不需要
- 兼容的系统
- 未声明(默认跨平台)
- 底层运行要求
- Python
- 文件与系统权限
-
- 只读
- 允许写入 / 修改
- Shell 执行
- 网络行为
- 允许外网请求
- 安装命令数
- 26 条
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
---
name: langchain-agents-deepagents-code
description: Use when editing a DeepAgents project — adding tools, sub-agents, modifying the system prompt, c…
category: AI 智能
runtime: Python
---
# langchain-agents-deepagents-code 输出预览
## PART A: 任务判断
- 适用问题:提示词、Agent 工作流、模型评估或自动化推理。
- 输入要求:目标材料、限制条件、期望输出和验收方式。
- 证据边界:围绕“What's new in 0.5.x (worth knowing before you build) / What DeepAgents actually is / Filesystem backend — pick deliberately for production”读取原文规则,不把推断写成作者承诺。
## PART B: 执行结果
- **01** 任务判断:确认你的需求是否属于提示词、Agent 工作流、模型评估或自动化推理,并标出输入、限制和预期结果。
- **02** 执行计划:优先按“What's new in 0.5.x (worth knowing before you build) / What DeepAgents actually is / Filesystem backend — pick deliberately for production”拆成步骤,说明每一步会读取什么、修改什么、产出什么。
- **03** 交付结果:给出可复制的命令、文件改动、检查清单或内容草稿,并说明如何继续迭代。
- **04** 风险边界:结合 读取文件、写入/修改文件、执行终端命令、会按任务需要访问外部网络、通常不需要额外 API Key 给出执行前确认项。
## Running Rules
- 读取文件、写入/修改文件、执行终端命令;会按任务需要访问外部网络;通常不需要额外 API Key。
- 先小样例验证,再放大到真实任务。
- 交付时同时给结果、检查口径和下一步迭代建议。 原文出现了 `/memories`、`/scratch` 这类斜杠命令;如果你的 Agent 支持命令触发,优先用命令开场,再补充目标和边界。
告诉 Agent 目标文件或材料、期望结果、不可改范围、是否允许联网或执行命令。本 Skill 的权限画像是:读取文件、写入/修改文件、执行终端命令。
先用一个小任务确认它会围绕“What's new in 0.5.x (worth knowing before you build) / What DeepAgents actually is / Filesystem backend — pick deliberately for production”工作;涉及文件或命令时,先看 diff、日志、预览或测试结果。
检查最终产物是否包含明确结果、必要证据和下一步动作;如果输出泛泛而谈,就补充输入、边界和验收标准后重跑。
---
name: langchain-agents-deepagents-code
description: Use when editing a DeepAgents project — adding tools, sub-agents, modifying the system prompt, c…
category: AI 智能
source: tomevault-io/skills-registry
---
# langchain-agents-deepagents-code
## 什么时候使用
- 把 AI / Agent方向的常用动作沉淀成 Agent 可调用的技能 适合处理AI Agent、提示词、模型评估与自动化推理,核心价值是把输入、判断、执行、验证和交付边界固定下来,避免 Agent 泛泛回答。 把任务拆成可执行、可检查…
- 面向提示词、Agent 工作流、模型评估或自动化推理,优先处理能明确输入、步骤和验收标准的工作。
## 需要提供什么
- 目标材料、目录范围、期望结果和不可改动内容。
- 是否允许联网、执行命令、读写文件或调用外部服务。
## 执行规则
- 围绕「What's new in 0.5.x (worth knowing before you build) / What DeepAgents actually is / Filesystem backend — pick deliberately for production」组织步骤,不把推断写成作者事实。
- 读取文件、写入/修改文件、执行终端命令;会按任务需要访问外部网络;通常不需要额外 API Key。
- 先跑小样例,确认结果可检查后再扩大任务范围。
## 输出要求
- 给出最终产物、关键证据、验证方式和下一步动作。
- 信息不足时标记 unknown,不编造命令、平台或依赖。 作者原文负责流程事实;仓库文件负责来源和命令;流狐只补充适用场景、限制和质量判断。
skill "langchain-agents-deepagents-code" {
输入层 -> 用户目标 + 目标文件 + 禁止范围 + 验收标准
上下文层 -> What's new in 0.5.x (worth knowing before you build) / What DeepAgents actually is / Filesystem backend — pick deliberately for production
规则层 -> SKILL.md 触发条件 / 执行顺序 / 输出格式
运行层 -> Python | 读取文件、写入/修改文件、执行终端命令 | 会按任务需要访问外部网络
安全层 -> 通常不需要额外 API Key + 小任务验证 + diff / 日志复核
输出层 -> 可复制结果 + 检查清单 + 下一步迭代
} DeepAgents: editorial guidance
Targets deepagents>=0.5.3. For API reference (signatures, kwargs, full middleware list), use the mcpdoc MCP tools: fetch_docs("https://docs.langchain.com/oss/python/deepagents/..."). This skill is the opinions layer.
What's new in 0.5.x (worth knowing before you build)
- Async sub-agents are first-class — sub-agents can now be
async defcallables and run withawait agent.ainvoke(...)end-to-end. Mix sync and async sub-agents in the samesubagents=[...]list. model=Noneis deprecated increate_deep_agent(0.5.3). Always pass an explicit model, e.g.init_chat_model("anthropic:claude-sonnet-4-6").- Filesystem permissions system (0.5.2) — route-scoped read/write rules on
CompositeBackend; sandbox is now the default for execution. Permission paths must start with/; path-traversal raisesValueError. - Structured sub-agent responses (0.5.3) — declare a Pydantic schema on a sub-agent and the parent receives a typed object instead of free text. Use this for "researcher returns a
Findingsobject" patterns. - Legacy subagents API removed (0.5.0). If you're upgrading from 0.4.x, the old kwargs are gone — see
subagents=[...]with the newSubAgentshape.
What DeepAgents actually is
create_deep_agent(...) is a thin wrapper over create_agent(...) that pre-installs three middlewares: FilesystemMiddleware (virtual FS + read_file/write_file/edit_file/ls/glob/grep), SubAgentMiddleware (the task tool with named sub-agents), and TodoListMiddleware (the write_todos planning tool). You can stack additional middlewares on top.
The implication: everything you know about agentic middleware applies. See langchain-agents-middleware for the production stack — DeepAgents projects benefit from it just like plain create_agent projects do.
Filesystem backend — pick deliberately for production
The default FilesystemMiddleware uses an in-memory virtual FS that resets between invocations unless you pass a checkpointer. For production, choose a backend:
| Backend | Scope | When |
|---|---|---|
| Default (in-memory) | Single invocation | Dev, tests |
StateBackend |
Single thread (with checkpointer) | Conversation memory only |
StoreBackend(namespace=(assistant_id, user_id)) |
Per-user persistent | Production: each user gets isolated files |
CompositeBackend |
Mix scopes | E.g. ephemeral scratch + persistent /memories/ |
StoreBackend namespaced by user is the production default. Don't ship a multi-user agent with the in-memory default — files would leak across users.
Filesystem permissions (0.5.2+) — on CompositeBackend you can scope read/write/exec permissions per route, with sandbox as the default. Permission paths must start with / (a leading ./ or path-traversal raises ValueError). Use this to make /memories/ read-only to a sub-agent that should only consume past notes, or to forbid writes outside /scratch/.
Sandboxed shell execution — read this before adding tool execution
For tools that run real shell commands, use ShellToolMiddleware with a sandboxed execution policy (Daytona is the primary supported sandbox). Two lifecycle patterns:
- Thread-scoped (most common): fresh container per conversation, cleaned up on TTL.
- Assistant-scoped: shared across conversations, preserves installed packages / cloned repos.
Critical rule the docs only mention in passing: never pass raw API keys into a sandbox. The agent can read_file any file the sandbox can. Use the auth proxy to inject credentials at call time. Treat sandboxes as adversarial environments.
Sub-agent design rules of thumb
- Sub-agent prompts are templates — the parent's
tasktool fills in{description}. Keep prompts generic; the parent decides the specifics. instructions=is for the top-level agent, not for sub-agents. Each sub-agent has its ownpromptfield.- Scope tools per sub-agent. A
researchersub-agent rarely needssend_email. The per-subagenttoolskey narrows the surface and improves reliability. - Don't nest sub-agents more than one level deep. Two-level nesting works; three-level becomes hard to reason about and hard to trace.
- Use async sub-agents (0.5+) when sub-agents do I/O — network fetches, vector store reads, MCP calls. Define the sub-agent function as
async def, drive the parent withawait agent.ainvoke(...), and the runtime parallelises sibling sub-agent calls automatically. Don't make a sub-agent async if its body is pure CPU. - Return structured outputs (0.5.3+) for downstream consumption. Attach a Pydantic
response_formatto a sub-agent and the parent'stasktool returns a typed object — much more reliable than parsing free-text findings.
# Async sub-agent with structured output
from pydantic import BaseModel
class Findings(BaseModel):
summary: str
sources: list[str]
async def research(state, runtime):
# ... do async I/O (web search, mcp calls) ...
return state
subagents = [
{
"name": "researcher",
"description": "Researches a topic and returns structured findings.",
"prompt": "Research {description} and return findings.",
"tools": [web_search],
"response_format": Findings,
"callable": research, # async def is supported
},
]
When to compose extra middlewares (almost always)
create_deep_agent accepts a middleware=[...] parameter that adds to (not replaces) the built-in three. For any production DeepAgent, layer the production stack on top:
from deepagents import create_deep_agent
from langchain.agents.middleware import (
ModelCallLimitMiddleware, ToolCallLimitMiddleware,
ModelRetryMiddleware, ToolRetryMiddleware,
ModelFallbackMiddleware, SummarizationMiddleware,
HumanInTheLoopMiddleware, PIIMiddleware,
)
agent = create_deep_agent(
model="claude-sonnet-4-6", # required as of 0.5.3 — `model=None` is deprecated
tools=TOOLS,
subagents=SUBAGENTS,
instructions=PROMPT,
middleware=[
ModelCallLimitMiddleware(run_limit=50),
ToolCallLimitMiddleware(run_limit=200),
ModelRetryMiddleware(max_retries=3),
ToolRetryMiddleware(max_retries=3),
ModelFallbackMiddleware("openai:gpt-4o-mini"),
SummarizationMiddleware(model="claude-haiku-4-5", trigger=("tokens", 8000), keep=("messages", 20)),
# HITL on irreversible tools — requires checkpointer
HumanInTheLoopMiddleware(interrupt_on={"send_email": {"allowed_decisions": ["approve","edit","reject"]}}),
PIIMiddleware("email", strategy="redact", apply_to_input=True),
],
)
Things the docs won't warn you about
- The virtual FS persists across
agent.invoke(...)calls within a single LangGraph run, but resets between runs unless you pass a checkpointer with a stablethread_id. - Adding
HumanInTheLoopMiddlewarerequires a checkpointer at compile time.create_deep_agentaccepts acheckpointer=parameter for this. - Sub-agents share the parent's tool registry by default. If a sub-agent should NOT see a tool, scope explicitly.
interrupt_on={...}set on the parent inherits to sub-agents (fixed in 0.5.0). If you want sub-agents to bypass HITL gates, override on the sub-agent definition.- Async sub-agents only run async if the parent is invoked with
ainvoke/astream— callingagent.invoke(...)on an async sub-agent runs it in a sync wrapper and you lose the parallelism benefit.
Doc URLs to fetch with mcpdoc
https://docs.langchain.com/oss/python/deepagents/index.md— overviewhttps://docs.langchain.com/oss/python/deepagents/going-to-production.md— backends, sandboxes, deploymenthttps://docs.langchain.com/oss/python/deepagents/memory.md— filesystem backends in depthhttps://docs.langchain.com/oss/python/deepagents/human-in-the-loop.md— HITL patterns
Source: cwijayasundara/agent_cli_langchain — distributed by TomeVault.
先判断是否适合
作者设计意图
作者的方法与取舍
边界和复核