> ## Documentation Index
> Fetch the complete documentation index at: https://nvd-54.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 智能体客户端协议 (ACP)

> 通过智能体客户端协议 (ACP) 暴露深度智能体，以便与代码编辑器和 IDE 集成。

[智能体客户端协议 (ACP)](https://agentclientprotocol.com/get-started/introduction) 标准化了编码智能体与代码编辑器或 IDE 之间的通信。
借助 ACP 协议，你可以在任何兼容 ACP 的客户端中使用你的自定义深度智能体，让代码编辑器能够提供项目上下文并接收丰富的更新。

<Note>
  ACP 专为智能体与编辑器的集成而设计。如果你希望智能体调用外部服务器托管的工具，请参阅[模型上下文协议 (MCP)](/oss/python/langchain/mcp/)。
</Note>

## 快速入门

安装 ACP 集成包：

<CodeGroup>
  ```bash pip theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  pip install deepagents-acp
  ```

  ```bash uv theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
  uv add deepagents-acp
  ```
</CodeGroup>

然后通过 ACP 暴露一个深度智能体。

这会以 stdio 模式启动一个 ACP 服务器（从 stdin 读取请求，将响应写入 stdout）。实际上，你通常将其作为由 ACP 客户端（例如你的编辑器）启动的命令来运行，客户端通过 stdio 与服务器通信。

```python icon="server" theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
import asyncio

from acp import run_agent
from deepagents import create_deep_agent
from langgraph.checkpoint.memory import MemorySaver

from deepagents_acp.server import AgentServerACP


async def main() -> None:
    agent = create_deep_agent(
        model="google_genai:gemini-3.1-pro-preview",
        # 你可以在此自定义深度智能体：设置自定义提示词，
        # 添加你自己的工具，附加中间件，或组合子智能体。
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)


if __name__ == "__main__":
    asyncio.run(main())
```

<Card title="示例编码智能体" icon="brand-github" href="https://github.com/langchain-ai/deepagents/blob/main/libs/acp/examples/demo_agent.py">
  `deepagents-acp` 包含一个带有文件系统和 shell 的示例编码智能体，你可以开箱即用。
</Card>

## 客户端

深度智能体可以在任何能运行 ACP 智能体服务器的地方工作。一些知名的 ACP 客户端包括：

* [Zed](https://zed.dev/docs/ai/external-agents)
* [JetBrains IDE](https://www.jetbrains.com/help/ai-assistant/acp.html)
* Visual Studio Code（通过 [vscode-acp](https://github.com/formulahendry/vscode-acp)）
* Neovim（通过兼容 ACP 的插件）

### Zed

`deepagents` 仓库包含了一个[演示 ACP 入口点](https://github.com/langchain-ai/deepagents/blob/main/libs/acp/run_demo_agent.sh)，你可以将其注册到 [Zed](https://zed.dev/docs/ai/external-agents)：

1. 克隆 `deepagents` 仓库并安装依赖：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
git clone https://github.com/langchain-ai/deepagents.git
cd deepagents/libs/acp
uv sync --all-groups
chmod +x run_demo_agent.sh
```

2. 为演示智能体配置凭证：

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
cp .env.example .env
```

然后在 `.env` 中设置 `ANTHROPIC_API_KEY`。

3. 在 Zed 的 `settings.json` 中配置你的 ACP 智能体服务器命令：

```json theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
{
  "agent_servers": {
    "DeepAgents": {
      "type": "custom",
      "command": "/your/absolute/path/to/deepagents/libs/acp/run_demo_agent.sh"
    }
  }
}
```

4. 打开 Zed 的 Agents 面板并启动一个 DeepAgents 线程。

### Toad

如果你想将 ACP 智能体服务器作为本地开发工具运行，可以使用 [Toad](https://github.com/batrachianai/toad) 来管理进程。

```bash theme={"theme":{"light":"catppuccin-latte","dark":"catppuccin-mocha"}}
uv tool install -U batrachian-toad

toad acp "python path/to/your_server.py" .
# 或
toad acp "uv run python path/to/your_server.py" .
```

<Info>
  查看上游 ACP 文档了解协议详情和编辑器支持：

  * 简介：[https://agentclientprotocol.com/get-started/introduction](https://agentclientprotocol.com/get-started/introduction)
  * 客户端/编辑器：[https://agentclientprotocol.com/get-started/clients](https://agentclientprotocol.com/get-started/clients)
</Info>

***

<div className="source-links">
  <Callout icon="terminal-2">
    [连接这些文档](/use-these-docs) 到 Claude、VSCode 等工具，通过 MCP 获取实时解答。
  </Callout>

  <Callout icon="edit">
    [在 GitHub 上编辑此页面](https://github.com/langchain-ai/docs/edit/main/src/oss/deepagents/acp.mdx) 或 [提交问题](https://github.com/langchain-ai/docs/issues/new/choose)。
  </Callout>
</div>
