managed-deep-agents

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Managed 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 (
    httpx
    in Python, built-in
    fetch
    in JS/Node 18+)
bash
export LANGSMITH_API_KEY="<LANGSMITH_API_KEY>"
export DEEPAGENTS_BASE_URL="https://api.smith.langchain.com/v1/deepagents"
All requests authenticate via the
X-Api-Key
header:
X-Api-Key: <LANGSMITH_API_KEY>
  • 对应工作区的LangSmith API密钥
  • 任意HTTP客户端(Python中使用
    httpx
    ,JS/Node 18+中使用内置
    fetch
bash
export LANGSMITH_API_KEY="<LANGSMITH_API_KEY>"
export DEEPAGENTS_BASE_URL="https://api.smith.langchain.com/v1/deepagents"
所有请求通过
X-Api-Key
头进行身份验证:
X-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 UI
Each 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

资源组

GroupPurpose
Agents (
/agents
)
Create, list, get, update (
PATCH
), and delete Managed Deep Agents.
Threads (
/threads
)
Create, search, count, and inspect durable thread state.
Runs (
/threads/{thread_id}/runs/stream
)
Start and stream runs on a thread (server-sent events).
MCP servers (
/mcp-servers
)
Register, list, rotate credentials, and delete MCP servers referenced by agent tools.
资源组用途
Agents (
/agents
)
创建、列出、获取、更新(
PATCH
)和删除Managed Deep Agents。
Threads (
/threads
)
创建、搜索、计数和查看持久化线程状态。
Runs (
/threads/{thread_id}/runs/stream
)
在线程上启动并流式返回运行结果(服务器发送事件)。
MCP servers (
/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
POST
/
PATCH /agents
payloads. The platform stores them as a versioned agent repo in the Context Hub, returns a
revision
on each update, and serves the tree to the agent on every run.
File / directoryPurpose
AGENTS.md
Agent instructions.
skills/
Skill definitions the agent can use.
subagents/
Subagent definitions for delegated work.
tools.json
Tool configuration (
tools
+
interrupt_config
).
At runtime, the agent can read and write files — including a
/memories/
directory for durable cross-run state.
Managed Deep Agents保留了熟悉的Deep Agents项目结构。请将这些文件保存在您的源码仓库中(以便更新可被审核),并在
POST
/
PATCH /agents
请求体中提交。平台会将它们作为版本化agent仓库存储在Context Hub中,每次更新时返回一个
revision
,并在每次运行时将文件树提供给agent。
文件/目录用途
AGENTS.md
Agent说明文档。
skills/
Agent可使用的Skill定义。
subagents/
用于委托工作的子agent定义。
tools.json
工具配置(
tools
+
interrupt_config
)。
在运行时,agent可以读写文件——包括用于跨运行持久化状态的
/memories/
目录。

tools
configuration

tools
配置

Tools are configured with a
tools
array and an
interrupt_config
map. The same shape is used in
tools.json
and inline in agent create/update payloads:
json
{
  "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
    tools[].mcp_server_url
    must match an MCP server already registered for the workspace; credentials are attached automatically at invocation time.
  • interrupt_config
    keys use the form
    {mcp_server_url}::{tool_name}
    (two colons, trailing slashes on the URL stripped before matching). Additional
    ::
    -separated parts (e.g. the MCP server display name) are accepted but ignored when matching.
  • Set the value to
    true
    to require human approval before the tool runs,
    false
    to allow it without interrupt.
工具通过
tools
数组和
interrupt_config
映射进行配置。
tools.json
和agent创建/更新请求体中的内联配置使用相同的结构:
json
{
  "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
  }
}
  • 每个
    tools[].mcp_server_url
    必须与工作区已注册的MCP服务器匹配;调用时会自动附加凭证。
  • interrupt_config
    的键采用
    {mcp_server_url}::{tool_name}
    格式(两个冒号,匹配前会去除URL末尾的斜杠)。额外的
    ::
    分隔部分(例如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
POST /v1/deepagents/mcp-servers
. The platform stores the URL and credential headers (encrypted at rest) and re-attaches them on every invocation whose
tools[].mcp_server_url
matches.
python
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:
ActionMethod + path
List
GET /mcp-servers
Get one
GET /mcp-servers/{mcp_server_id}
Rotate credentials
PATCH /mcp-servers/{mcp_server_id}
(replaces the entire
headers
array — partial diffs not supported)
Delete
DELETE /mcp-servers/{mcp_server_id}
Only static-header auth (bearer tokens, custom API-key headers) is supported during preview. OAuth-backed MCP servers are planned.
需要凭证的工具(自定义MCP服务器、私有端点、任何基于Bearer认证的API)需通过
POST /v1/deepagents/mcp-servers
在每个工作区注册一次。平台会存储URL和凭证头(静态加密),并在每次调用时,当
tools[].mcp_server_url
匹配时重新附加这些信息。
python
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"]
同一资源的其他操作:
操作方法 + 路径
列出
GET /mcp-servers
获取单个
GET /mcp-servers/{mcp_server_id}
轮换凭证
PATCH /mcp-servers/{mcp_server_id}
(替换整个
headers
数组——不支持部分差异更新)
删除
DELETE /mcp-servers/{mcp_server_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
id
(store it as
AGENT_ID
).
Other operations:
ActionMethod + path
List
GET /agents
Get one
GET /agents/{agent_id}
Update
PATCH /agents/{agent_id}
Delete
DELETE /agents/{agent_id}
PATCH
replaces
tools
wholesale
— to add a tool, pass the full new tool set, not just the additions. Each
PATCH
also creates a new
revision
on the agent's Context Hub repo.
Deleting an agent does NOT cascade to its threads. Existing threads remain queryable but starting new runs returns
502
. Track and delete threads explicitly when cleaning up.
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"]
响应包含agent的
id
(请将其保存为
AGENT_ID
)。
其他操作:
操作方法 + 路径
列出
GET /agents
获取单个
GET /agents/{agent_id}
更新
PATCH /agents/{agent_id}
删除
DELETE /agents/{agent_id}
PATCH
会完全替换
tools
——要添加工具,请传递完整的新工具集,而不仅仅是新增的工具。每次
PATCH
还会在agent的Context Hub仓库中创建一个新的
revision
删除agent不会级联删除其线程。现有线程仍可查询,但启动新运行会返回
502
。清理时请显式跟踪并删除线程。

Supported models

支持的模型

Pass model identifiers in
{provider}:{model_id}
form (e.g.
anthropic:claude-sonnet-4-6
,
openai:gpt-5.4-mini
). The runtime resolves models with
init_chat_model
, so any provider supported by
init_chat_model
works.
Values without a colon are interpreted as references to a saved Playground configuration, not a model ID — always supply the full
{provider}:{model_id}
form when configuring a model directly.
请以
{provider}:{model_id}
格式传递模型标识符(例如
anthropic:claude-sonnet-4-6
openai:gpt-5.4-mini
)。运行时通过
init_chat_model
解析模型,因此
init_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
Accept: text/event-stream
so the client receives progress as SSE.
stream_mode
accepts the same values as the LangGraph runtime (
values
,
updates
,
messages-tuple
, etc.).
stream_subgraphs: true
emits events from subagent graphs as well as the parent.
Every 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)
设置
Accept: text/event-stream
,以便客户端以SSE形式接收进度。
stream_mode
接受与LangGraph运行时相同的值(
values
updates
messages-tuple
等)。
stream_subgraphs: true
会同时发送子agent图和父agent图的事件。
每次运行都会在LangSmith中生成跟踪——模型调用、工具调用、子agent活动、文件和运行时状态都可以从跟踪UI中查看。

JavaScript / cURL equivalents

JavaScript / cURL等效实现

The same flow works with
fetch
(Node 18+ or browser) or
curl
. Replace
httpx.post(url, headers=HEADERS, json=...)
with:
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
curl
, set
--header "X-Api-Key: $LANGSMITH_API_KEY"
and
--header 'Content-Type: application/json'
.
相同的流程也适用于
fetch
(Node 18+或浏览器)或
curl
。将
httpx.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]] (
langgraph deploy
) instead when you need:
  • 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]](
langgraph deploy
)进行标准LangSmith部署:
  • agent周围的自定义应用代码或自定义路由
  • 高级身份验证
  • 完整的Agent Server API接口
  • 更强的隔离控制或最大可扩展性
  • 美国LangSmith Cloud以外的区域,或自托管/混合部署

Gotchas

注意事项

  • No SDK — REST is the only supported interface. Python/JS/
    useStream
    SDK wrappers are in progress.
  • No rate limits during preview — but quotas may be introduced before GA; don't design around the absence of limits.
  • PATCH
    is wholesale, not partial
    — both for
    agents
    (
    tools
    field is replaced) and for
    mcp-servers
    (
    headers
    array is replaced). Always send the full new value.
  • interrupt_config
    key format
    {mcp_server_url}::{tool_name}
    with two colons. Trailing slashes on the URL are stripped before matching.
  • Model IDs must include the provider prefix
    anthropic:claude-sonnet-4-6
    , not
    claude-sonnet-4-6
    (the latter is treated as a Playground config reference).
  • MCP credentials are sensitive
    headers
    is omitted from response bodies for callers without invoke permission; treat list/get responses as sensitive and avoid logging them verbatim.
  • 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
    502
    . Clean up threads explicitly.
  • API stability — routes live under
    /v1/deepagents
    but the surface may change in backwards-incompatible ways before GA. Breaking changes are communicated directly to preview customers.
  • 无SDK——REST是唯一支持的接口。Python/JS/
    useStream
    SDK封装正在开发中。
  • 预览期间无速率限制——但正式发布前可能会引入配额;请勿依赖无限制的设计。
  • PATCH
    是全量更新,而非部分更新
    ——对于
    agents
    tools
    字段会被替换)和
    mcp-servers
    headers
    数组会被替换)都是如此。请始终发送完整的新值。
  • interrupt_config
    键格式
    ——
    {mcp_server_url}::{tool_name}
    ,使用两个冒号。匹配前会去除URL末尾的斜杠。
  • 模型ID必须包含提供商前缀——例如
    anthropic:claude-sonnet-4-6
    ,而非
    claude-sonnet-4-6
    (后者会被视为Playground配置引用)。
  • MCP凭证敏感——对于没有调用权限的调用者,响应体中会省略
    headers
    ;请将列表/获取响应视为敏感信息,避免逐字记录日志。
  • MCP认证仅限于静态头——预览期间仅支持Bearer令牌和自定义API密钥头。基于OAuth的注册正在规划中。
  • 删除agent不会删除其线程——在孤立线程上启动新运行会返回
    502
    。请显式清理线程。
  • API稳定性——路由位于
    /v1/deepagents
    下,但正式发布前接口可能会发生不兼容变更。变更会直接通知预览客户。