managed-deep-agents
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseManaged Deep Agents
Managed Deep Agents
Overview
概述
Managed Deep Agents is an API-first hosted runtime for creating, running, and operating Deep Agents in LangSmith. It packages the operational layer around the open-source Deep Agents harness — versioned agent repo in the Context Hub, durable threads, streamed runs, managed file tree, MCP credential storage — so you don't have to stand up your own agent server.
For self-hosted deployments or full Agent Server APIs, use a standard LangSmith Deployment via [[langgraph-cli]] instead.
Managed Deep Agents是LangSmith中一款以API优先的托管运行时,用于创建、运行和操作Deep Agents。它封装了围绕开源Deep Agents harness的操作层——包括Context Hub中的版本化agent仓库、持久化线程、流式运行、托管文件树、MCP凭证存储——因此您无需自行搭建agent服务器。
如果需要自托管部署或完整的Agent Server API,请改用[[langgraph-cli]]进行标准LangSmith部署。
When to use
适用场景
Use this skill when the user wants to:
- Create or update a Managed Deep Agent (/
POST)PATCH /v1/deepagents/agents - Run an agent on a durable thread and stream the result
- Register or rotate MCP server credentials for an agent's tools
- Configure per-tool human-in-the-loop interrupts on a managed agent
- Decide between Managed Deep Agents and a self-hosted LangSmith Deployment
当用户有以下需求时,使用此Skill:
- 创建或更新Managed Deep Agent(/
POST)PATCH /v1/deepagents/agents - 在持久化线程上运行agent并流式返回结果
- 为agent的工具注册或轮换MCP服务器凭证
- 为托管agent配置按工具划分的人工介入中断
- 在Managed Deep Agents和自托管LangSmith部署之间做选择
Prerequisites
前提条件
- A LangSmith API key for that workspace
- The HTTP client of your choice (in Python, built-in
httpxin JS/Node 18+)fetch
bash
export LANGSMITH_API_KEY="<LANGSMITH_API_KEY>"
export DEEPAGENTS_BASE_URL="https://api.smith.langchain.com/v1/deepagents"All requests authenticate via the header:
X-Api-KeyX-Api-Key: <LANGSMITH_API_KEY>- 对应工作区的LangSmith API密钥
- 任意HTTP客户端(Python中使用,JS/Node 18+中使用内置
httpx)fetch
bash
export LANGSMITH_API_KEY="<LANGSMITH_API_KEY>"
export DEEPAGENTS_BASE_URL="https://api.smith.langchain.com/v1/deepagents"所有请求通过头进行身份验证:
X-Api-KeyX-Api-Key: <LANGSMITH_API_KEY>End-to-end flow
端到端流程
1. Register MCP server(s) → POST /v1/deepagents/mcp-servers
2. Create the agent → POST /v1/deepagents/agents
3. Create a thread → POST /v1/deepagents/threads
4. Stream a run → POST /v1/deepagents/threads/{thread_id}/runs/stream
5. Inspect in LangSmith → Traces UIEach step is independent — register MCP servers once per workspace, then point any number of agents at them.
1. 注册MCP服务器 → POST /v1/deepagents/mcp-servers
2. 创建agent → POST /v1/deepagents/agents
3. 创建线程 → POST /v1/deepagents/threads
4. 流式运行 → POST /v1/deepagents/threads/{thread_id}/runs/stream
5. 在LangSmith中查看 → Traces UI每个步骤相互独立——每个工作区只需注册一次MCP服务器,之后可将任意数量的agent指向这些服务器。
Resource groups
资源组
| Group | Purpose |
|---|---|
Agents ( | Create, list, get, update ( |
Threads ( | Create, search, count, and inspect durable thread state. |
Runs ( | Start and stream runs on a thread (server-sent events). |
MCP servers ( | Register, list, rotate credentials, and delete MCP servers referenced by agent tools. |
| 资源组 | 用途 |
|---|---|
Agents ( | 创建、列出、获取、更新( |
Threads ( | 创建、搜索、计数和查看持久化线程状态。 |
Runs ( | 在线程上启动并流式返回运行结果(服务器发送事件)。 |
MCP servers ( | 注册、列出、轮换凭证和删除agent工具引用的MCP服务器。 |
Agent file tree
Agent文件树
Managed Deep Agents keeps the familiar Deep Agents project shape. Keep these in your source repo (so updates are reviewable) and submit them in / payloads. The platform stores them as a versioned agent repo in the Context Hub, returns a on each update, and serves the tree to the agent on every run.
POSTPATCH /agentsrevision| File / directory | Purpose |
|---|---|
| Agent instructions. |
| Skill definitions the agent can use. |
| Subagent definitions for delegated work. |
| Tool configuration ( |
At runtime, the agent can read and write files — including a directory for durable cross-run state.
/memories/Managed Deep Agents保留了熟悉的Deep Agents项目结构。请将这些文件保存在您的源码仓库中(以便更新可被审核),并在 / 请求体中提交。平台会将它们作为版本化agent仓库存储在Context Hub中,每次更新时返回一个,并在每次运行时将文件树提供给agent。
POSTPATCH /agentsrevision| 文件/目录 | 用途 |
|---|---|
| Agent说明文档。 |
| Agent可使用的Skill定义。 |
| 用于委托工作的子agent定义。 |
| 工具配置( |
在运行时,agent可以读写文件——包括用于跨运行持久化状态的目录。
/memories/tools
configuration
toolstools
配置
toolsTools are configured with a array and an map. The same shape is used in and inline in agent create/update payloads:
toolsinterrupt_configtools.jsonjson
{
"tools": [
{
"name": "tavily-search",
"mcp_server_url": "https://mcp.tavily.com/mcp/",
"mcp_server_name": "tavily",
"display_name": "tavily-search"
}
],
"interrupt_config": {
"https://mcp.tavily.com/mcp/::tavily-search::tavily": false
}
}- Each must match an MCP server already registered for the workspace; credentials are attached automatically at invocation time.
tools[].mcp_server_url - keys use the form
interrupt_config(two colons, trailing slashes on the URL stripped before matching). Additional{mcp_server_url}::{tool_name}-separated parts (e.g. the MCP server display name) are accepted but ignored when matching.:: - Set the value to to require human approval before the tool runs,
trueto allow it without interrupt.false
工具通过数组和映射进行配置。和agent创建/更新请求体中的内联配置使用相同的结构:
toolsinterrupt_configtools.jsonjson
{
"tools": [
{
"name": "tavily-search",
"mcp_server_url": "https://mcp.tavily.com/mcp/",
"mcp_server_name": "tavily",
"display_name": "tavily-search"
}
],
"interrupt_config": {
"https://mcp.tavily.com/mcp/::tavily-search::tavily": false
}
}- 每个必须与工作区已注册的MCP服务器匹配;调用时会自动附加凭证。
tools[].mcp_server_url - 的键采用
interrupt_config格式(两个冒号,匹配前会去除URL末尾的斜杠)。额外的{mcp_server_url}::{tool_name}分隔部分(例如MCP服务器显示名称)会被接受但匹配时会被忽略。:: - 将值设置为表示工具运行前需要人工批准,设置为
true表示无需中断即可运行。false
Step 1 — Register an MCP server
步骤1 — 注册MCP服务器
Tools that need credentials (custom MCP servers, private endpoints, any bearer-authenticated API) are registered once per workspace via . The platform stores the URL and credential headers (encrypted at rest) and re-attaches them on every invocation whose matches.
POST /v1/deepagents/mcp-serverstools[].mcp_server_urlpython
import os, httpx
BASE_URL = os.environ["DEEPAGENTS_BASE_URL"]
HEADERS = {"X-Api-Key": os.environ["LANGSMITH_API_KEY"]}
response = httpx.post(
f"{BASE_URL}/mcp-servers",
headers=HEADERS,
json={
"name": "tavily",
"url": "https://mcp.tavily.com/mcp/",
"headers": [
{"key": "Authorization", "value": "Bearer tvly-..."},
],
},
)
response.raise_for_status()
mcp_server_id = response.json()["id"]Other operations on the same resource:
| Action | Method + path |
|---|---|
| List | |
| Get one | |
| Rotate credentials | |
| Delete | |
Only static-header auth (bearer tokens, custom API-key headers) is supported during preview. OAuth-backed MCP servers are planned.
需要凭证的工具(自定义MCP服务器、私有端点、任何基于Bearer认证的API)需通过在每个工作区注册一次。平台会存储URL和凭证头(静态加密),并在每次调用时,当匹配时重新附加这些信息。
POST /v1/deepagents/mcp-serverstools[].mcp_server_urlpython
import os, httpx
BASE_URL = os.environ["DEEPAGENTS_BASE_URL"]
HEADERS = {"X-Api-Key": os.environ["LANGSMITH_API_KEY"]}
response = httpx.post(
f"{BASE_URL}/mcp-servers",
headers=HEADERS,
json={
"name": "tavily",
"url": "https://mcp.tavily.com/mcp/",
"headers": [
{"key": "Authorization", "value": "Bearer tvly-..."},
],
},
)
response.raise_for_status()
mcp_server_id = response.json()["id"]同一资源的其他操作:
| 操作 | 方法 + 路径 |
|---|---|
| 列出 | |
| 获取单个 | |
| 轮换凭证 | |
| 删除 | |
预览期间仅支持静态头认证(Bearer令牌、自定义API密钥头)。基于OAuth的MCP服务器正在规划中。
Step 2 — Create the managed agent
步骤2 — 创建托管agent
python
response = httpx.post(
f"{BASE_URL}/agents",
headers=HEADERS,
json={
"name": "research-assistant",
"description": "Research assistant that can search the web and summarize sources.",
"runtime": {"model": {"model_id": "anthropic:claude-sonnet-4-6"}},
"instructions": (
"You are a careful research assistant. Search for sources, "
"keep notes, and return concise answers with citations."
),
"tools": {
"tools": [
{
"name": "tavily-search",
"mcp_server_url": "https://mcp.tavily.com/mcp/",
"mcp_server_name": "tavily",
"display_name": "tavily-search",
},
],
"interrupt_config": {
"https://mcp.tavily.com/mcp/::tavily-search::tavily": False,
},
},
},
)
response.raise_for_status()
agent_id = response.json()["id"]Response includes the agent (store it as ).
idAGENT_IDOther operations:
| Action | Method + path |
|---|---|
| List | |
| Get one | |
| Update | |
| Delete | |
PATCHtoolsPATCHrevisionDeleting an agent does NOT cascade to its threads. Existing threads remain queryable but starting new runs returns . Track and delete threads explicitly when cleaning up.
502python
response = httpx.post(
f"{BASE_URL}/agents",
headers=HEADERS,
json={
"name": "research-assistant",
"description": "Research assistant that can search the web and summarize sources.",
"runtime": {"model": {"model_id": "anthropic:claude-sonnet-4-6"}},
"instructions": (
"You are a careful research assistant. Search for sources, "
"keep notes, and return concise answers with citations."
),
"tools": {
"tools": [
{
"name": "tavily-search",
"mcp_server_url": "https://mcp.tavily.com/mcp/",
"mcp_server_name": "tavily",
"display_name": "tavily-search",
},
],
"interrupt_config": {
"https://mcp.tavily.com/mcp/::tavily-search::tavily": False,
},
},
},
)
response.raise_for_status()
agent_id = response.json()["id"]响应包含agent的(请将其保存为)。
idAGENT_ID其他操作:
| 操作 | 方法 + 路径 |
|---|---|
| 列出 | |
| 获取单个 | |
| 更新 | |
| 删除 | |
PATCHtoolsPATCHrevision删除agent不会级联删除其线程。现有线程仍可查询,但启动新运行会返回。清理时请显式跟踪并删除线程。
502Supported models
支持的模型
Pass model identifiers in form (e.g. , ). The runtime resolves models with , so any provider supported by works.
{provider}:{model_id}anthropic:claude-sonnet-4-6openai:gpt-5.4-miniinit_chat_modelinit_chat_modelValues without a colon are interpreted as references to a saved Playground configuration, not a model ID — always supply the full form when configuring a model directly.
{provider}:{model_id}请以格式传递模型标识符(例如、)。运行时通过解析模型,因此支持的所有提供商都可以使用。
{provider}:{model_id}anthropic:claude-sonnet-4-6openai:gpt-5.4-miniinit_chat_modelinit_chat_model不包含冒号的值会被解释为对已保存的Playground配置的引用,而非模型ID——直接配置模型时,请始终提供完整的格式。
{provider}:{model_id}Step 3 — Create a thread
步骤3 — 创建线程
Threads preserve conversation and execution state for long-running work.
python
response = httpx.post(
f"{BASE_URL}/threads",
headers=HEADERS,
json={
"agent_id": agent_id,
"options": {
"test_run": False,
"skip_memory_write_protection": False,
},
},
)
response.raise_for_status()
thread_id = response.json()["id"]线程为长期运行的工作保留对话和执行状态。
python
response = httpx.post(
f"{BASE_URL}/threads",
headers=HEADERS,
json={
"agent_id": agent_id,
"options": {
"test_run": False,
"skip_memory_write_protection": False,
},
},
)
response.raise_for_status()
thread_id = response.json()["id"]Step 4 — Stream a run
步骤4 — 流式运行
python
payload = {
"agent_id": agent_id,
"messages": [
{
"role": "user",
"content": "Research recent approaches to agent memory and summarize the main tradeoffs.",
}
],
"stream_mode": ["values", "updates", "messages-tuple"],
"stream_subgraphs": True,
"user_timezone": "America/Los_Angeles",
}
with httpx.stream(
"POST",
f"{BASE_URL}/threads/{thread_id}/runs/stream",
headers={**HEADERS, "Accept": "text/event-stream"},
json=payload,
timeout=None,
) as response:
response.raise_for_status()
for line in response.iter_lines():
if line:
print(line)Set so the client receives progress as SSE. accepts the same values as the LangGraph runtime (, , , etc.). emits events from subagent graphs as well as the parent.
Accept: text/event-streamstream_modevaluesupdatesmessages-tuplestream_subgraphs: trueEvery run is traced in LangSmith — model calls, tool calls, subagent activity, files, and runtime state are all inspectable from the trace UI.
python
payload = {
"agent_id": agent_id,
"messages": [
{
"role": "user",
"content": "Research recent approaches to agent memory and summarize the main tradeoffs.",
}
],
"stream_mode": ["values", "updates", "messages-tuple"],
"stream_subgraphs": True,
"user_timezone": "America/Los_Angeles",
}
with httpx.stream(
"POST",
f"{BASE_URL}/threads/{thread_id}/runs/stream",
headers={**HEADERS, "Accept": "text/event-stream"},
json=payload,
timeout=None,
) as response:
response.raise_for_status()
for line in response.iter_lines():
if line:
print(line)设置,以便客户端以SSE形式接收进度。接受与LangGraph运行时相同的值(、、等)。会同时发送子agent图和父agent图的事件。
Accept: text/event-streamstream_modevaluesupdatesmessages-tuplestream_subgraphs: true每次运行都会在LangSmith中生成跟踪——模型调用、工具调用、子agent活动、文件和运行时状态都可以从跟踪UI中查看。
JavaScript / cURL equivalents
JavaScript / cURL等效实现
The same flow works with (Node 18+ or browser) or . Replace with:
fetchcurlhttpx.post(url, headers=HEADERS, json=...)javascript
const BASE_URL = process.env.DEEPAGENTS_BASE_URL;
const HEADERS = {
"X-Api-Key": process.env.LANGSMITH_API_KEY,
"Content-Type": "application/json",
};
const response = await fetch(`${BASE_URL}/agents`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({ /* same payload */ }),
});
if (!response.ok) throw new Error(await response.text());
const { id: agentId } = await response.json();For streaming, read from .
response.body.pipeThrough(new TextDecoderStream()).getReader()For , set and .
curl--header "X-Api-Key: $LANGSMITH_API_KEY"--header 'Content-Type: application/json'相同的流程也适用于(Node 18+或浏览器)或。将替换为:
fetchcurlhttpx.post(url, headers=HEADERS, json=...)javascript
const BASE_URL = process.env.DEEPAGENTS_BASE_URL;
const HEADERS = {
"X-Api-Key": process.env.LANGSMITH_API_KEY,
"Content-Type": "application/json",
};
const response = await fetch(`${BASE_URL}/agents`, {
method: "POST",
headers: HEADERS,
body: JSON.stringify({ /* same payload */ }),
});
if (!response.ok) throw new Error(await response.text());
const { id: agentId } = await response.json();流式处理时,请从读取内容。
response.body.pipeThrough(new TextDecoderStream()).getReader()使用时,请设置和。
curl--header "X-Api-Key: $LANGSMITH_API_KEY"--header 'Content-Type: application/json'When NOT to use Managed Deep Agents
不适用场景
Use a standard LangSmith Deployment via [[langgraph-cli]] () instead when you need:
langgraph deploy- Custom application code or custom routes around the agent
- Advanced authentication
- The full Agent Server API surface
- Stronger isolation controls or maximum scalability
- A region other than US LangSmith Cloud, or self-hosted/Hybrid
当您需要以下功能时,请改用[[langgraph-cli]]()进行标准LangSmith部署:
langgraph deploy- agent周围的自定义应用代码或自定义路由
- 高级身份验证
- 完整的Agent Server API接口
- 更强的隔离控制或最大可扩展性
- 美国LangSmith Cloud以外的区域,或自托管/混合部署
Gotchas
注意事项
- No SDK — REST is the only supported interface. Python/JS/SDK wrappers are in progress.
useStream - No rate limits during preview — but quotas may be introduced before GA; don't design around the absence of limits.
- is wholesale, not partial — both for
PATCH(agentsfield is replaced) and fortools(mcp-serversarray is replaced). Always send the full new value.headers - key format —
interrupt_configwith two colons. Trailing slashes on the URL are stripped before matching.{mcp_server_url}::{tool_name} - Model IDs must include the provider prefix — , not
anthropic:claude-sonnet-4-6(the latter is treated as a Playground config reference).claude-sonnet-4-6 - MCP credentials are sensitive — is omitted from response bodies for callers without invoke permission; treat list/get responses as sensitive and avoid logging them verbatim.
headers - MCP auth limited to static headers — bearer tokens and custom API-key headers only during preview. OAuth-backed registration is planned.
- Deleting an agent does not delete its threads — and new runs on orphaned threads return . Clean up threads explicitly.
502 - API stability — routes live under but the surface may change in backwards-incompatible ways before GA. Breaking changes are communicated directly to preview customers.
/v1/deepagents
- 无SDK——REST是唯一支持的接口。Python/JS/SDK封装正在开发中。
useStream - 预览期间无速率限制——但正式发布前可能会引入配额;请勿依赖无限制的设计。
- 是全量更新,而非部分更新——对于
PATCH(agents字段会被替换)和tools(mcp-servers数组会被替换)都是如此。请始终发送完整的新值。headers - 键格式——
interrupt_config,使用两个冒号。匹配前会去除URL末尾的斜杠。{mcp_server_url}::{tool_name} - 模型ID必须包含提供商前缀——例如,而非
anthropic:claude-sonnet-4-6(后者会被视为Playground配置引用)。claude-sonnet-4-6 - MCP凭证敏感——对于没有调用权限的调用者,响应体中会省略;请将列表/获取响应视为敏感信息,避免逐字记录日志。
headers - MCP认证仅限于静态头——预览期间仅支持Bearer令牌和自定义API密钥头。基于OAuth的注册正在规划中。
- 删除agent不会删除其线程——在孤立线程上启动新运行会返回。请显式清理线程。
502 - API稳定性——路由位于下,但正式发布前接口可能会发生不兼容变更。变更会直接通知预览客户。
/v1/deepagents