Skip to content

Commit 5ad351c

Browse files
authored
docs: fix v2 quickstart, web transport snippets, and example annotations (#219)
1 parent d5560c3 commit 5ad351c

5 files changed

Lines changed: 54 additions & 13 deletions

File tree

‎docs/experimental-v2.md‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ class MyAgent(v2.Agent):
5151
async def new_session(self, cwd: str, **kwargs: Any) -> v2.schema.NewSessionResponse:
5252
return v2.schema.NewSessionResponse(session_id="session-1")
5353

54+
async def prompt(
55+
self, session_id: str, prompt: list[v2.schema.ContentBlock], **kwargs: Any
56+
) -> v2.schema.PromptResponse:
57+
return v2.schema.PromptResponse(message_id="msg-1")
58+
5459

5560
await v2.run_agent(MyAgent())
5661
```
@@ -84,6 +89,6 @@ The router calls each version's factory and `on_connect` at most once per connec
8489

8590
## Extensions, cancellation, and MCP-over-ACP
8691

87-
- 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.
92+
- 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).
8893
- `$/cancel_request` cancels running handler tasks and outgoing requests automatically; use `cancel_session(session_id=...)` for active session work.
8994
- [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 = {}`.

‎docs/web-transport.md‎

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,31 @@ pip install "agent-client-protocol[http]"
1212

1313
## Client usage
1414

15-
Pass a Streamable HTTP or WebSocket transport into `connect_to_agent`:
15+
Pass either a Streamable HTTP or a WebSocket transport into `connect_to_agent`:
1616

1717
```python
1818
from acp import PROTOCOL_VERSION, connect_to_agent
1919
from acp.http import create_http_stream
20-
from acp.ws import create_websocket_stream
2120

22-
# Streamable HTTP
2321
transport = create_http_stream("http://localhost:8000/acp")
2422
conn = connect_to_agent(my_client, transport)
25-
26-
# WebSocket
27-
transport = await create_websocket_stream("ws://localhost:8000/acp")
28-
conn = connect_to_agent(my_client, transport)
29-
3023
await conn.initialize(protocol_version=PROTOCOL_VERSION)
3124
session = await conn.new_session(cwd="/tmp", mcp_servers=[])
3225
await conn.prompt(session_id=session.session_id, prompt=[...])
3326
await conn.close()
3427
await transport.close()
3528
```
3629

30+
Or connect over WebSocket:
31+
32+
```python
33+
from acp import connect_to_agent
34+
from acp.ws import create_websocket_stream
35+
36+
transport = await create_websocket_stream("ws://localhost:8000/acp")
37+
conn = connect_to_agent(my_client, transport)
38+
```
39+
3740
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.
3841

3942
## Server usage

‎examples/agent.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
)
1616
from acp.interfaces import Client
1717
from acp.schema import (
18+
AcpMcpServer,
1819
AgentCapabilities,
1920
AgentMessageChunk,
2021
AudioContentBlock,
@@ -66,7 +67,7 @@ async def new_session(
6667
self,
6768
cwd: str,
6869
additional_directories: list[str] | None = None,
69-
mcp_servers: list[HttpMcpServer | SseMcpServer | McpServerStdio] | None = None,
70+
mcp_servers: list[HttpMcpServer | SseMcpServer | AcpMcpServer | McpServerStdio] | None = None,
7071
**kwargs: Any,
7172
) -> NewSessionResponse:
7273
logging.info("Received new session request")
@@ -79,8 +80,8 @@ async def load_session(
7980
self,
8081
cwd: str,
8182
session_id: str,
83+
mcp_servers: list[HttpMcpServer | SseMcpServer | AcpMcpServer | McpServerStdio] | None = None,
8284
additional_directories: list[str] | None = None,
83-
mcp_servers: list[HttpMcpServer | SseMcpServer | McpServerStdio] | None = None,
8485
**kwargs: Any,
8586
) -> LoadSessionResponse | None:
8687
logging.info("Received load session request %s", session_id)

‎examples/client.py‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@
4040
RequestPermissionResponse,
4141
ResourceContentBlock,
4242
SessionInfoUpdate,
43+
SessionUpdateCompactionSummaryChunk,
44+
SessionUpdateCompactionUpdate,
45+
SessionUpdateCursorUpdate,
46+
SessionUpdateNotice,
47+
SessionUpdatePromptSuggestionsUpdate,
48+
SessionUpdateSessionMessage,
49+
SessionUpdateSessionMessageChunk,
50+
SessionUpdateSubagentUpdate,
4351
TerminalOutputResponse,
4452
TextContentBlock,
4553
ToolCallProgress,
@@ -118,7 +126,15 @@ async def session_update(
118126
| CurrentModeUpdate
119127
| ConfigOptionUpdate
120128
| SessionInfoUpdate
121-
| UsageUpdate,
129+
| UsageUpdate
130+
| SessionUpdateNotice
131+
| SessionUpdateCompactionUpdate
132+
| SessionUpdateCompactionSummaryChunk
133+
| SessionUpdatePromptSuggestionsUpdate
134+
| SessionUpdateCursorUpdate
135+
| SessionUpdateSubagentUpdate
136+
| SessionUpdateSessionMessage
137+
| SessionUpdateSessionMessageChunk,
122138
**kwargs: Any,
123139
) -> None:
124140
if not isinstance(update, AgentMessageChunk):

‎examples/gemini.py‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@
4646
RequestPermissionResponse,
4747
ResourceContentBlock,
4848
SessionInfoUpdate,
49+
SessionUpdateCompactionSummaryChunk,
50+
SessionUpdateCompactionUpdate,
51+
SessionUpdateCursorUpdate,
52+
SessionUpdateNotice,
53+
SessionUpdatePromptSuggestionsUpdate,
54+
SessionUpdateSessionMessage,
55+
SessionUpdateSessionMessageChunk,
56+
SessionUpdateSubagentUpdate,
4957
TerminalOutputResponse,
5058
TerminalToolCallContent,
5159
TextContentBlock,
@@ -134,7 +142,15 @@ async def session_update( # noqa: C901
134142
| CurrentModeUpdate
135143
| ConfigOptionUpdate
136144
| SessionInfoUpdate
137-
| UsageUpdate,
145+
| UsageUpdate
146+
| SessionUpdateNotice
147+
| SessionUpdateCompactionUpdate
148+
| SessionUpdateCompactionSummaryChunk
149+
| SessionUpdatePromptSuggestionsUpdate
150+
| SessionUpdateCursorUpdate
151+
| SessionUpdateSubagentUpdate
152+
| SessionUpdateSessionMessage
153+
| SessionUpdateSessionMessageChunk,
138154
**kwargs: Any,
139155
) -> None:
140156
if isinstance(update, AgentMessageChunk):

0 commit comments

Comments
 (0)