Skip to content
LangChain 文档版本 跟随上游 源快照 cb803032 更新于 2026-10-08

Agent Client Protocol (ACP)

通过 Agent Client Protocol (ACP) 暴露 Deep Agents,以便与代码编辑器和 IDE 集成。

Agent Client Protocol (ACP) 标准化了编码智能体与代码编辑器或 IDE 之间的通信。 借助 ACP 协议,你可以在任何 ACP 兼容的客户端中使用你的自定义深度智能体,让你的代码编辑器能够提供项目上下文并接收丰富的更新。

NOTE

ACP 是为智能体-编辑器集成而设计的。如果你希望你的智能体调用由外部服务器托管的工具,请参阅 Model Context Protocol (MCP)。

快速开始

安装 ACP 集成包:

bash
pip install deepagents-acp
bash
uv add deepagents-acp

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

这会在 stdio 模式下启动一个 ACP 服务器(它从 stdin 读取请求并将响应写入 stdout)。在实践中,你通常将它作为由 ACP 客户端(例如你的编辑器)启动的命令来运行,然后该客户端通过 stdio 与服务器通信。

python
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.6-flash",
        # You can customize your deep agent here: set a custom prompt,
        # add your own tools, attach middleware, or compose subagents.
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)

if __name__ == "__main__":
    asyncio.run(main())
python
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="openai:gpt-5.5",
        # You can customize your deep agent here: set a custom prompt,
        # add your own tools, attach middleware, or compose subagents.
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)

if __name__ == "__main__":
    asyncio.run(main())
python
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="anthropic:claude-sonnet-5",
        # You can customize your deep agent here: set a custom prompt,
        # add your own tools, attach middleware, or compose subagents.
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)

if __name__ == "__main__":
    asyncio.run(main())
python
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="openrouter:z-ai/glm-5.2",
        # You can customize your deep agent here: set a custom prompt,
        # add your own tools, attach middleware, or compose subagents.
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)

if __name__ == "__main__":
    asyncio.run(main())
python
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="fireworks:accounts/fireworks/models/glm-5p2",
        # You can customize your deep agent here: set a custom prompt,
        # add your own tools, attach middleware, or compose subagents.
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)

if __name__ == "__main__":
    asyncio.run(main())
python
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="baseten:zai-org/GLM-5.2",
        # You can customize your deep agent here: set a custom prompt,
        # add your own tools, attach middleware, or compose subagents.
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)

if __name__ == "__main__":
    asyncio.run(main())
python
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="ollama:north-mini-code-1.0",
        # You can customize your deep agent here: set a custom prompt,
        # add your own tools, attach middleware, or compose subagents.
        system_prompt="You are a helpful coding assistant",
        checkpointer=MemorySaver(),
    )

    server = AgentServerACP(agent)
    await run_agent(server)

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

Example coding agent

deepagents-acp 包包含一个带有文件系统和 shell 的示例编码智能体,开箱即用。

客户端

深度智能体可以在任何你能运行 ACP 智能体服务器的地方工作。一些值得注意的 ACP 客户端包括:

Zed

deepagents 仓库包含一个演示 ACP 入口点,你可以将其注册到 Zed:

  1. 克隆 deepagents 仓库并安装依赖项:
bash
git clone https://github.com/langchain-ai/deepagents.git
cd deepagents/libs/acp
uv sync --all-groups
chmod +x run_demo_agent.sh
  1. 为演示智能体配置凭证:
bash
cp .env.example .env

然后在 .env 中设置 ANTHROPIC_API_KEY。

  1. 在 Zed 的 settings.json 中配置你的 ACP 智能体服务器命令:
json
{
  "agent_servers": {
    "DeepAgents": {
      "type": "custom",
      "command": "/your/absolute/path/to/deepagents/libs/acp/run_demo_agent.sh"
    }
  }
}
  1. 打开 Zed 的 Agents 面板并启动一个 Deep Agents 线程。

Toad

如果你想把 ACP 智能体服务器作为本地开发工具运行,可以使用 Toad 来管理该进程。

bash
uv tool install -U batrachian-toad

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

INFO

有关协议细节和编辑器支持,请参阅上游 ACP 文档:


BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。