From e7772f7907baa266c4cadb215e17e4f43cee6cc6 Mon Sep 17 00:00:00 2001 From: Chojan Shang Date: Mon, 30 Nov 2026 21:00:02 +0800 Subject: [PATCH 1/2] docs: reorganize guides, add API reference and 1.x migration guide --- README.md | 13 +++--- docs/api-reference.md | 84 +++++++++++++++++++++++++++++++++++++ docs/experimental-v2.md | 17 ++++---- docs/index.md | 27 ++++++------ docs/migration-guide-1.x.md | 74 ++++++++++++++++++++++++++++++++ docs/quickstart.md | 40 +++++++++++------- docs/web-transport.md | 32 +++++++++----- mkdocs.yml | 18 +++++--- 8 files changed, 248 insertions(+), 57 deletions(-) create mode 100644 docs/api-reference.md create mode 100644 docs/migration-guide-1.x.md diff --git a/README.md b/README.md index 4bbf8727..60ffb848 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,8 @@ Python SDK for building [Agent Client Protocol (ACP)](https://agentclientprotocol.com/) agents and clients, with generated Pydantic models and asyncio transports over stdio, Streamable HTTP, and WebSocket. +> **ACP v2 is in Preview:** "Preview is the same stage our RFDs go through before we complete them. The work is implemented and ready for broad review. For v2, that means we think the design is settled enough to build on. If you were waiting for the Draft to stop moving before you started, this is the time to start." — [ACP v2 is available in Preview](https://agentclientprotocol.com/announcements/acp-v2-preview) · See the [Protocol v2 (Preview) guide](https://agentclientprotocol.github.io/python-sdk/experimental-v2/). + ## Installation ```bash @@ -19,7 +21,7 @@ pip install agent-client-protocol uv add agent-client-protocol ``` -For experimental HTTP/WebSocket transports, install the `http` extra (`pip install "agent-client-protocol[http]"`). Requires Python 3.10–3.15. +For experimental Streamable HTTP and WebSocket transports, install the `http` extra (`pip install "agent-client-protocol[http]"`). Requires Python 3.10–3.15. ## Quick example @@ -87,11 +89,12 @@ asyncio.run(main()) ## Documentation -- [Quickstart](https://agentclientprotocol.github.io/python-sdk/quickstart/) — Connect your agent to Zed, Toad, Lody, or T3 Code, or drive agents programmatically. -- [Protocol Features](https://agentclientprotocol.github.io/python-sdk/protocol-features/) — Unstable opt-in methods, session notices, stateless MCP-over-ACP, cancellation, and extensions (`schema-v1.35.0`). +- [Quickstart](https://agentclientprotocol.github.io/python-sdk/quickstart/) — Connect an agent to Zed, Toad, Lody, or T3 Code, or drive agents from Python. +- [Protocol Features (v1)](https://agentclientprotocol.github.io/python-sdk/protocol-features/) — Unstable opt-in methods, session notices, stateless MCP-over-ACP, cancellation, and extensions. - [Web Transport](https://agentclientprotocol.github.io/python-sdk/web-transport/) — Serve and consume ACP over Streamable HTTP and WebSocket (`[http]`). -- [Experimental Protocol v2](https://agentclientprotocol.github.io/python-sdk/experimental-v2/) — Preview v2 runtime (`schema-v2.0.0-beta.4`) and dual-stack `AgentProtocolRouter`. -- [Examples](https://github.com/agentclientprotocol/python-sdk/tree/main/examples) · [Contrib](https://agentclientprotocol.github.io/python-sdk/contrib/) · [Use Cases](https://agentclientprotocol.github.io/python-sdk/use-cases/) · [Testing](https://agentclientprotocol.github.io/python-sdk/testing/) +- [Protocol v2 (Preview)](https://agentclientprotocol.github.io/python-sdk/experimental-v2/) — Preview v2 runtime and dual-stack `AgentProtocolRouter`. +- [API Reference](https://agentclientprotocol.github.io/python-sdk/api-reference/) — Core entrypoints, connection classes, transports, and contrib helpers. +- [Examples](https://github.com/agentclientprotocol/python-sdk/tree/main/examples) · [Contrib](https://agentclientprotocol.github.io/python-sdk/contrib/) · [Use Cases](https://agentclientprotocol.github.io/python-sdk/use-cases/) · [Testing](https://agentclientprotocol.github.io/python-sdk/testing/) · [Migration Guides](https://agentclientprotocol.github.io/python-sdk/migration-guide-1.x/) ## Development diff --git a/docs/api-reference.md b/docs/api-reference.md new file mode 100644 index 00000000..3e188df7 --- /dev/null +++ b/docs/api-reference.md @@ -0,0 +1,84 @@ +# API Reference + +Core public entrypoints for building and driving ACP agents and clients. Generated Pydantic schema models live in `acp.schema` (v1) and `acp.experimental.v2.schema` (v2). + +## Core (v1) + +::: acp.core.run_agent + +::: acp.core.connect_to_agent + +::: acp.stdio.spawn_agent_process + +::: acp.stdio.spawn_client_process + +::: acp.agent.connection.AgentSideConnection + options: + members: + - __init__ + - listen + - session_update + - request_permission + - ext_method + - ext_notification + - close + +::: acp.client.connection.ClientSideConnection + options: + members: + - __init__ + - initialize + - new_session + - load_session + - resume_session + - prompt + - cancel + - ext_method + - ext_notification + - close + +## Protocol v2 (Preview) & Negotiation + +::: acp.experimental.negotiation.AgentProtocolRouter + options: + members: + - __init__ + - connect + - run + +::: acp.experimental.v2.agent.run_agent + +::: acp.experimental.v2.client.connect_to_agent + +## Web Transport (`[http]`) + +::: acp.http.client.create_http_stream + +::: acp.http.asgi.create_asgi_app + +::: acp.ws.client.create_websocket_stream + +## Contrib Utilities + +::: acp.contrib.session_state.SessionAccumulator + options: + members: + - apply + - snapshot + - subscribe + - reset + +::: acp.contrib.tool_calls.ToolCallTracker + options: + members: + - start + - progress + - append_stream_text + - view + - tool_call_model + - forget + +::: acp.contrib.permissions.PermissionBroker + options: + members: + - request_for diff --git a/docs/experimental-v2.md b/docs/experimental-v2.md index bfd26161..179fe48c 100644 --- a/docs/experimental-v2.md +++ b/docs/experimental-v2.md @@ -1,8 +1,8 @@ -# Experimental Protocol v2 +# Protocol v2 (Preview) -> **Preview.** Protocol v2 lives under `acp.experimental` and tracks [`schema-v2.0.0-beta.4`](https://github.com/agentclientprotocol/agent-client-protocol/releases/tag/schema-v2.0.0-beta.4). +> "Preview is the same stage our RFDs go through before we complete them. The work is implemented and ready for broad review. For v2, that means we think the design is settled enough to build on. If you were waiting for the Draft to stop moving before you started, this is the time to start." — [ACP v2 is available in Preview](https://agentclientprotocol.com/announcements/acp-v2-preview) -Connection methods and agent/client handlers accept expanded snake_case parameters, responses and nested payloads use `acp.experimental.v2.schema` models, and extra keyword arguments serialize into `_meta`. +Protocol v2 bindings and runtime live under `acp.experimental.v2` and track [`schema-v2.0.0-beta.4`](https://github.com/agentclientprotocol/agent-client-protocol/releases/tag/schema-v2.0.0-beta.4). Connection methods and handlers accept expanded snake_case parameters, nested payloads use `acp.experimental.v2.schema` models, and extra keyword arguments serialize into `_meta`. ## Client and agent usage @@ -15,7 +15,7 @@ from acp.experimental import v2 class MyClient(v2.Client): async def session_update(self, session_id: str, update: v2.schema.SessionUpdate, **kwargs: Any) -> None: - handle_update(session_id, update) + print(session_id, update) connection = v2.connect_to_agent(MyClient(), transport) @@ -60,15 +60,14 @@ class MyAgent(v2.Agent): await v2.run_agent(MyAgent()) ``` -V2 connections require a successful `initialize` handshake before other methods and validate requests and responses strictly. -If the agent rejects `initialize`, the client can retry on the same connection. A rejected repeat leaves the previous successful initialization in effect. +V2 connections require a successful `initialize` handshake before other methods and validate requests and responses strictly. If the agent rejects `initialize`, the client can retry on the same connection; a rejected repeat leaves the previous successful initialization in effect. ## Key v2 behaviors - **Asynchronous prompt submission**: `session/prompt` returns `PromptResponse(message_id=...)` once the user message is accepted, while updates stream independently. Pass `idempotency_key` (1–255 chars) so retried submissions reuse the original `message_id`. - **Expanded union calls**: `set_config_option` infers `type` (`"boolean"` for `bool`, `"id"` otherwise, or pass a custom `type`); `create_elicitation` accepts either `session_id` or `request_id` along with form or URL parameters. - **Patch updates**: In updates like `SessionToolCallUpdate` and `SessionTerminalUpdate`, omit a field to keep its value or pass `None` to clear it. Serialize with `update.model_dump(by_alias=True, exclude_unset=True)` to preserve that distinction. -- **Notices and replay**: Agents can emit live advisory `v2.schema.SessionNotice(...)` updates, and clients can request retained history via `resume_session(..., replay_from=v2.schema.ReplayFromStartVariant())`. +- **Notices, subagents, and replay**: Agents can emit live `v2.schema.SessionNotice(...)` and `v2.schema.SessionSubagentUpdate(...)` updates, and clients can request retained history via `resume_session(..., replay_from=v2.schema.ReplayFromStartVariant())`, ending with `SessionReplayComplete`. - **Reusable union aliases**: `v2.schema` exports `SessionUpdate`, `ContentBlock`, `StateUpdate`, `BackgroundWork`, and `AvailableCommand`. ## Dual-stack v1/v2 negotiation @@ -85,10 +84,10 @@ router = AgentProtocolRouter( await router.run() ``` -The router calls each version's factory and `on_connect` at most once per connection. Before sending another request, the client can repeat `initialize` with the selected version or downgrade to a lower supported version. The router switches protocol versions after a successful downgrade. +The router calls each version's factory and `on_connect` at most once per connection. Before sending another request, the client can repeat `initialize` with the selected version or downgrade to a lower supported version; the router switches protocol versions after a successful downgrade. ## Extensions, cancellation, and MCP-over-ACP -- Call `ext_method("vendor/method", ...)` and `ext_notification("vendor/event", ...)` on connections, and implement `ext_method`, `ext_notification`, or `on_connect` on `v2.Agent` / `v2.Client` for vendor extensions and connection setup (the SDK prepends and strips the wire `_` prefix, matching v1). +- Call `ext_method("vendor/method", ...)` and `ext_notification("vendor/event", ...)` on connections, and implement `ext_method`, `ext_notification`, or `on_connect` on `v2.Agent` / `v2.Client` (the SDK prepends and strips the wire `_` prefix, matching v1). - `$/cancel_request` cancels running handler tasks and outgoing requests automatically; use `cancel_session(session_id=...)` for active session work. - [Stateless MCP-over-ACP](protocol-features.md#stateless-mcp-over-acp) uses `v2.schema.McpResultResponse`, `McpErrorResponse`, and `MessageMcpResponse` when the agent advertises `capabilities.session.mcp.acp = {}`. diff --git a/docs/index.md b/docs/index.md index 256cfabc..cf94cdd2 100644 --- a/docs/index.md +++ b/docs/index.md @@ -4,25 +4,28 @@ # Agent Client Protocol SDK (Python) -Build ACP agents and clients in Python with generated Pydantic models and asyncio transports over stdio, Streamable HTTP, and WebSocket. +Build [Agent Client Protocol (ACP)](https://agentclientprotocol.com/) agents and clients in Python with generated Pydantic models and asyncio transports over stdio, Streamable HTTP, and WebSocket. + +> **ACP v2 is available in Preview:** "Preview is the same stage our RFDs go through before we complete them. The work is implemented and ready for broad review. For v2, that means we think the design is settled enough to build on. If you were waiting for the Draft to stop moving before you started, this is the time to start." — [ACP v2 is available in Preview](https://agentclientprotocol.com/announcements/acp-v2-preview) ```bash pip install agent-client-protocol -# Optional: pip install "agent-client-protocol[http]" +# Optional remote transports: +pip install "agent-client-protocol[http]" ``` -## Where to start +## Guides -- **[Quickstart](quickstart.md)** — Run the echo agent, wire it into an editor or CLI client, and write your first custom agent. -- **[Protocol Features (v1)](protocol-features.md)** — Use unstable opt-in features, session notices, stateless MCP-over-ACP, request cancellation, and extension methods. -- **[Web Transport](web-transport.md)** — Run ACP over Streamable HTTP (HTTP/2 + SSE) and WebSocket with Starlette. -- **[Experimental Protocol v2](experimental-v2.md)** — Explore the preview v2 API (`schema-v2.0.0-beta.4`) and dual-stack `AgentProtocolRouter`. -- **[Contrib Utilities](contrib.md)** — Reuse stateful helpers for session aggregation, tool call tracking, and permission prompts. +- **[Quickstart](quickstart.md)** — Connect an agent to an ACP client, spawn agents from Python, and stream messages and tool calls. +- **[Protocol Features (v1)](protocol-features.md)** — Enable unstable methods, stream session notices, bridge stateless MCP-over-ACP, cancel requests, and add extensions. +- **[Web Transport](web-transport.md)** — Run ACP over Streamable HTTP and WebSocket with Starlette. +- **[Protocol v2 (Preview)](experimental-v2.md)** — Build on the v2 preview runtime and serve v1/v2 together with `AgentProtocolRouter`. +- **[Contrib Utilities](contrib.md)** — Reuse stateful helpers for session snapshots, tool call tracking, and permission prompts. -## Ecosystem and operations +## Reference & Project -- **[Use Cases](use-cases.md)** — Agents and clients built with this SDK. -- **[Testing & Conformance](testing.md)** — Local checks, ACP TCK conformance, and real-world interoperability checks. -- **[Releasing](releasing.md)** — Schema updates and release workflow. +- **[API Reference](api-reference.md)** — Signatures and docstrings for the primary SDK entrypoints. +- **[Migration Guides](migration-guide-1.x.md)** — Upgrade notes for 1.x and earlier releases. +- **[Use Cases](use-cases.md)** · **[Testing & Conformance](testing.md)** · **[Releasing](releasing.md)** Questions and feedback are welcome in [GitHub Discussions](https://github.com/agentclientprotocol/python-sdk/discussions) and on [Zulip](https://agentclientprotocol.zulipchat.com/). diff --git a/docs/migration-guide-1.x.md b/docs/migration-guide-1.x.md new file mode 100644 index 00000000..e99126ab --- /dev/null +++ b/docs/migration-guide-1.x.md @@ -0,0 +1,74 @@ +# Migrating to ACP Python SDK 1.x + +Key breaking changes when upgrading from `0.12.x` to `1.0.0` and from `1.0.x` to `1.1.0`. + +## 0.12.x to 1.0.0 + +### 1. Construct `acp.schema` models directly + +`acp.helpers` and its top-level builder functions (`text_block`, `update_agent_message_text`, `start_tool_call`, and friends) were removed. Instantiate generated models from `acp.schema` directly — discriminator fields such as `type` and `sessionUpdate` have defaults: + +```python +from acp.schema import AgentMessageChunk, TextContentBlock, ToolCallStart + +chunk = AgentMessageChunk(content=TextContentBlock(text="Hello")) +tool_call = ToolCallStart(tool_call_id="call-1", title="Read file", kind="read", status="in_progress") +``` + +### 2. Update authentication and schema types + +- `EnvVarAuthMethod` was replaced by `TerminalAuthMethod`. +- `ToolCall` and `ToolCallUpdate` gained an optional programmatic `name` field. +- Accepted elicitation responses validate content strictly against `acp.schema` models. + +### 3. Install the `[http]` extra for web transports + +Streamable HTTP and WebSocket transports moved to Starlette and `httpx2[http2]` under the optional `http` extra: + +```bash +pip install "agent-client-protocol[http]" +``` + +See [Web Transport](web-transport.md) for current client and ASGI server usage. + +## 1.0.x to 1.1.0 + +Changes in `1.1.0` primarily affect **unstable** protocol features updated by the upstream `schema-v1.35.0` release: + +### 1. Move MCP-over-ACP to stateless `mcp_message` + +`connect_mcp` and `disconnect_mcp` were removed. Unstable MCP-over-ACP now uses stateless `mcp_message` requests and `notify_mcp` notifications keyed by `server_id` and `request_id`: + +```python +from uuid import uuid4 + +from acp.schema import McpErrorResponse + +response = await conn.mcp_message( + server_id="project-tools", + request_id=uuid4().hex, + method="tools/list", + params={}, +) +if isinstance(response, McpErrorResponse): + print("MCP error:", response.error) +``` + +See [Stateless MCP-over-ACP](protocol-features.md#stateless-mcp-over-acp) for the full handshake and metadata keys. + +### 2. Remove dropped unstable methods + +- Next edit suggestions (`start_nes`, `suggest_nes`, `close_nes`, `accept_nes`, `reject_nes`) and document notifications (`did_open`, `did_change`, `did_close`, `did_save`, `did_focus`) were removed. +- `PlanUpdateFile` was removed alongside the schema's `file` plan update variant. + +### 3. Expect stricter validation on local models and `mcpServers` + +- Passing an invalid local Pydantic model instance inside a list field now raises `ValidationError` instead of being silently dropped. +- A malformed entry in `session/new`'s `mcpServers` list now raises `ValidationError` instead of being skipped. + +## Verify after upgrading + +```bash +make check +make test +``` diff --git a/docs/quickstart.md b/docs/quickstart.md index a254d165..757f9fae 100644 --- a/docs/quickstart.md +++ b/docs/quickstart.md @@ -1,6 +1,6 @@ # Quickstart -Launch a streaming ACP agent and connect a client in a few minutes (requires Python 3.10–3.15). +Launch a streaming ACP agent and drive it from an editor or Python process in a few minutes (requires Python 3.10–3.15). ## 1. Install @@ -10,7 +10,7 @@ pip install agent-client-protocol uv add agent-client-protocol ``` -## 2. Run the echo agent and connect a client +## 2. Connect the echo agent to a client `examples/echo_agent.py` is a runnable stdio agent that streams incoming prompt text back as `session/update` notifications: @@ -34,7 +34,7 @@ Point any stdio ACP client (such as Zed, Toad, Lody, or T3 Code) at that command ## 3. Drive an agent from Python -Use `spawn_agent_process` to start an agent subprocess, exchange JSON-RPC messages over stdio, and close both cleanly on exit: +Use `spawn_agent_process` to start an agent subprocess over stdio, run a prompt turn, and close both sides cleanly when the context exits: ```python import asyncio @@ -43,12 +43,14 @@ from pathlib import Path from typing import Any from acp import PROTOCOL_VERSION, Client, spawn_agent_process -from acp.schema import TextContentBlock +from acp.schema import DeniedOutcome, RequestPermissionResponse, TextContentBlock class SimpleClient(Client): - async def request_permission(self, session_id: str, tool_call: Any, options: list[Any], **kwargs: Any) -> Any: - return {"outcome": {"outcome": "cancelled"}} + async def request_permission( + self, session_id: str, tool_call: Any, options: list[Any], **kwargs: Any + ) -> RequestPermissionResponse: + return RequestPermissionResponse(outcome=DeniedOutcome()) async def session_update(self, session_id: str, update: Any, **kwargs: Any) -> None: print("update:", session_id, update) @@ -67,9 +69,9 @@ asyncio.run(main()) `spawn_client_process` provides the matching helper when an agent spawns a client subprocess. -## 4. Write your own agent +## 4. Stream tool calls and replies from your own agent -Subclass `acp.Agent`, implement the methods your agent supports, and start serving with `acp.run_agent()`: +Subclass `acp.Agent`, implement the methods you support, and serve over stdio with `acp.run_agent()`. Generated models populate discriminator fields (`type`, `sessionUpdate`) automatically, and extra keyword arguments serialize into JSON-RPC `_meta`: ```python import asyncio @@ -78,10 +80,10 @@ from uuid import uuid4 from acp import PROTOCOL_VERSION, Agent, InitializeResponse, NewSessionResponse, PromptResponse, run_agent from acp.interfaces import Client -from acp.schema import AgentMessageChunk, TextContentBlock +from acp.schema import AgentMessageChunk, TextContentBlock, ToolCallProgress, ToolCallStart -class MyAgent(Agent): +class StatusAgent(Agent): def on_connect(self, conn: Client) -> None: self._conn = conn @@ -94,18 +96,24 @@ class MyAgent(Agent): async def prompt(self, session_id: str, prompt: list[Any], **kwargs: Any) -> PromptResponse: await self._conn.session_update( session_id=session_id, - update=AgentMessageChunk(content=TextContentBlock(text="Hello!")), + update=ToolCallStart(tool_call_id="call-1", title="Inspect workspace", kind="read", status="in_progress"), + ) + await self._conn.session_update( + session_id=session_id, + update=ToolCallProgress(tool_call_id="call-1", status="completed"), + ) + await self._conn.session_update( + session_id=session_id, + update=AgentMessageChunk(content=TextContentBlock(text="Workspace check complete.")), ) return PromptResponse(stop_reason="end_turn") if __name__ == "__main__": - asyncio.run(run_agent(MyAgent())) + asyncio.run(run_agent(StatusAgent())) ``` -Generated schema models populate discriminator fields (`type`, `sessionUpdate`) automatically, so models like `AgentMessageChunk(content=TextContentBlock(text="Hello!"))` can be constructed directly. Extra keyword arguments on connection calls and handlers carry JSON-RPC `_meta`. - ## Next steps -- Browse [`examples/`](https://github.com/agentclientprotocol/python-sdk/tree/main/examples) for fuller agent, client, HTTP/WS, MCP-over-ACP, and Gemini CLI demos. -- Continue to [Protocol Features (v1)](protocol-features.md), [Web Transport](web-transport.md), or [Experimental Protocol v2](experimental-v2.md). +- Browse [`examples/`](https://github.com/agentclientprotocol/python-sdk/tree/main/examples) for fuller agent, client, HTTP/WebSocket, MCP-over-ACP, and Gemini CLI scripts. +- Continue to [Protocol Features (v1)](protocol-features.md), [Web Transport](web-transport.md), [Protocol v2 (Preview)](experimental-v2.md), or the [API Reference](api-reference.md). diff --git a/docs/web-transport.md b/docs/web-transport.md index 86588d82..fcd89c31 100644 --- a/docs/web-transport.md +++ b/docs/web-transport.md @@ -1,8 +1,8 @@ -# Web Transport (Streamable HTTP & WebSocket) +# Web Transport > **Experimental.** Shipped under the optional `[http]` extra. -Run ACP remotely over **Streamable HTTP** (`POST` requests + HTTP/2 SSE `GET` streams + `DELETE` teardown) or **WebSocket** (full-duplex JSON-RPC text frames) using the same `Agent` and `Client` APIs. +Run ACP remotely over **Streamable HTTP** (`POST` requests + SSE `GET` streams + `DELETE` teardown) or **WebSocket** (full-duplex JSON-RPC text frames) using the same `Agent` and `Client` APIs. ## Installation @@ -12,17 +12,18 @@ pip install "agent-client-protocol[http]" ## Client usage -Pass either a Streamable HTTP or a WebSocket transport into `connect_to_agent`: +Pass a Streamable HTTP transport into `connect_to_agent`: ```python from acp import PROTOCOL_VERSION, connect_to_agent from acp.http import create_http_stream +from acp.schema import TextContentBlock transport = create_http_stream("http://localhost:8000/acp") conn = connect_to_agent(my_client, transport) await conn.initialize(protocol_version=PROTOCOL_VERSION) session = await conn.new_session(cwd="/tmp", mcp_servers=[]) -await conn.prompt(session_id=session.session_id, prompt=[...]) +await conn.prompt(session_id=session.session_id, prompt=[TextContentBlock(text="Hello!")]) await conn.close() await transport.close() ``` @@ -30,11 +31,17 @@ await transport.close() Or connect over WebSocket: ```python -from acp import connect_to_agent +from acp import PROTOCOL_VERSION, connect_to_agent +from acp.schema import TextContentBlock from acp.ws import create_websocket_stream transport = await create_websocket_stream("ws://localhost:8000/acp") conn = connect_to_agent(my_client, transport) +await conn.initialize(protocol_version=PROTOCOL_VERSION) +session = await conn.new_session(cwd="/tmp", mcp_servers=[]) +await conn.prompt(session_id=session.session_id, prompt=[TextContentBlock(text="Hello!")]) +await conn.close() +await transport.close() ``` Both transports also support `load_session()` and `resume_session()` when advertised by the agent, streaming replay updates over the connection channel before switching to live session traffic. @@ -49,20 +56,25 @@ from acp.http.asgi import create_asgi_app app = create_asgi_app(lambda conn: MyAgent()) ``` -Pass an `AgentProtocolRouter` to serve v2 or negotiate v1/v2 over the same endpoint: +Pass an `AgentProtocolRouter` to serve v2 or negotiate v1 and v2 on the same endpoint: ```python from acp.experimental import AgentProtocolRouter from acp.http.asgi import create_asgi_app -app = create_asgi_app(AgentProtocolRouter(v1=lambda conn: V1Agent(conn), v2=lambda conn: V2Agent(conn))) +app = create_asgi_app( + AgentProtocolRouter( + v1=lambda conn: V1Agent(conn), + v2=lambda conn: V2Agent(conn), + ) +) ``` -When mounting `app` inside another Starlette application, enter `acp_app.router.lifespan_context(acp_app)` from the parent lifespan so active HTTP connections close cleanly on shutdown. +When mounting `app` inside another Starlette application, enter `acp_app.router.lifespan_context(acp_app)` from the parent lifespan so active connections close cleanly on shutdown. -### Running with HTTP/2 +### Serving with HTTP/2 -Streamable HTTP requires an HTTP/2-capable ASGI server such as **Hypercorn**, **Daphne**, or **Granian** (or HTTP/2 termination at a reverse proxy). WebSocket works on any ASGI server, including Uvicorn. +HTTP/2 is recommended for Streamable HTTP so concurrent `POST` requests and SSE streams multiplex cleanly over one connection. Run `app` behind an HTTP/2-capable ASGI server such as **Hypercorn**, **Daphne**, or **Granian** (or terminate HTTP/2 at a reverse proxy); WebSocket works on any ASGI server, including Uvicorn. ```python import asyncio diff --git a/mkdocs.yml b/mkdocs.yml index c708ec57..4ad91b62 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -8,18 +8,21 @@ repo_name: agentclientprotocol/python-sdk copyright: Maintained by psiace. nav: - - Overview: index.md + - Home: index.md - Quickstart: quickstart.md - Guides: - Protocol Features (v1): protocol-features.md - - Web Transport (HTTP & WebSocket): web-transport.md - - Experimental Protocol v2: experimental-v2.md + - Web Transport: web-transport.md + - Protocol v2 (Preview): experimental-v2.md - Contrib Utilities: contrib.md - - Ecosystem & Quality: + - Reference: + - API Reference: api-reference.md + - Project: - Use Cases: use-cases.md - Testing & Conformance: testing.md - Releasing: releasing.md - Migration Guides: + - 1.x Migration Guide: migration-guide-1.x.md - 0.11 Migration Guide: migration-guide-0.11.md - 0.8 Migration Guide: migration-guide-0.8.md - 0.7 Migration Guide: migration-guide-0.7.md @@ -28,7 +31,12 @@ plugins: - mkdocstrings: handlers: python: - paths: ["src/acp"] + paths: ["src"] + options: + show_root_heading: true + show_source: false + members_order: source + filters: ["!^_"] theme: name: material feature: From 7d7d22144a7adb47728f37f725ae1087a67014a8 Mon Sep 17 00:00:00 2001 From: Chojan Shang Date: Mon, 30 Nov 2026 21:14:01 +0800 Subject: [PATCH 2/2] docs: drop experimental label from Streamable HTTP and WebSocket transports --- AGENTS.md | 2 +- README.md | 2 +- docs/web-transport.md | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 263c2816..a222ac0d 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -7,7 +7,7 @@ Use this page as the quick orientation for the Python SDK repo. It mirrors the t | Path | Why it exists | | --- | --- | | `src/acp/` | Runtime package: agent/client bases, transports, helpers, schema bindings, contrib utilities | -| `src/acp/http/`, `src/acp/ws/` | Experimental remote transports (Streamable HTTP + WebSocket), client + server; opt-in via the `[http]` extra | +| `src/acp/http/`, `src/acp/ws/` | Remote transports (Streamable HTTP + WebSocket), client + server; opt-in via the `[http]` extra | | `schema/` | Upstream JSON schema sources (regenerate with `make gen-all`) | | `examples/` | Runnable scripts such as `echo_agent.py`, `client.py`, `gemini.py`, `duet.py` | | `tests/` | Pytest suite, including optional Gemini smoke tests in `tests/test_gemini_example.py` | diff --git a/README.md b/README.md index 60ffb848..05a8cea1 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ pip install agent-client-protocol uv add agent-client-protocol ``` -For experimental Streamable HTTP and WebSocket transports, install the `http` extra (`pip install "agent-client-protocol[http]"`). Requires Python 3.10–3.15. +For Streamable HTTP and WebSocket transports, install the `http` extra (`pip install "agent-client-protocol[http]"`). Requires Python 3.10–3.15. ## Quick example diff --git a/docs/web-transport.md b/docs/web-transport.md index fcd89c31..806f6ea7 100644 --- a/docs/web-transport.md +++ b/docs/web-transport.md @@ -1,8 +1,6 @@ # Web Transport -> **Experimental.** Shipped under the optional `[http]` extra. - -Run ACP remotely over **Streamable HTTP** (`POST` requests + SSE `GET` streams + `DELETE` teardown) or **WebSocket** (full-duplex JSON-RPC text frames) using the same `Agent` and `Client` APIs. +Run ACP remotely over **Streamable HTTP** (`POST` requests + SSE `GET` streams + `DELETE` teardown) or **WebSocket** (full-duplex JSON-RPC text frames) using the optional `[http]` extra and the same `Agent` and `Client` APIs. ## Installation