You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+39-6Lines changed: 39 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,9 +6,10 @@ Python SDK for the Agent Client Protocol (ACP). Build agents that speak ACP over
6
6
7
7
**Highlights**
8
8
9
-
- Typed dataclasses generated from the upstream ACP schema (`acp.schema`)
10
-
- Async agent base class plus stdio transport helpers for quick bootstrapping
11
-
- Included examples that stream content updates and tool calls end-to-end
9
+
- Generated `pydantic` models that track the upstream ACP schema (`acp.schema`)
10
+
- Async base classes and JSON-RPC plumbing that keep stdio agents tiny
11
+
- Process helpers such as `spawn_agent_process` for embedding agents and clients directly in Python
12
+
- Batteries-included examples that exercise streaming updates, file I/O, and permission flows
12
13
13
14
## Install
14
15
@@ -29,6 +30,37 @@ uv add agent-client-protocol
29
30
30
31
Prefer a step-by-step walkthrough? Read the [Quickstart guide](docs/quickstart.md) or the hosted docs: https://psiace.github.io/agent-client-protocol-python/.
31
32
33
+
### Launching from Python
34
+
35
+
Embed the agent inside another Python process without spawning your own pipes:
36
+
37
+
```python
38
+
import asyncio
39
+
import sys
40
+
from pathlib import Path
41
+
42
+
from acp import spawn_agent_process
43
+
from acp.schema import InitializeRequest, NewSessionRequest, PromptRequest, TextContentBlock
44
+
45
+
46
+
asyncdefmain() -> None:
47
+
agent_script = Path("examples/echo_agent.py")
48
+
asyncwith spawn_agent_process(lambda_agent: YourClient(), sys.executable, str(agent_script)) as (conn, _proc):
Copy file name to clipboardExpand all lines: docs/index.md
+6-5Lines changed: 6 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,9 +4,10 @@ Welcome to the Python SDK for the Agent Client Protocol (ACP). The package ships
4
4
5
5
## What you get
6
6
7
-
- Fully typed dataclasses generated from the upstream ACP schema (`acp.schema`)
8
-
- Async agent base class and stdio helpers to spin up an agent in a few lines
9
-
- Examples that demonstrate streaming updates and tool execution over ACP
7
+
- Pydantic models generated from the upstream ACP schema (`acp.schema`)
8
+
- Async agent/client wrappers with JSON-RPC task supervision built in
9
+
- Process helpers (`spawn_agent_process`, `spawn_client_process`) for embedding ACP nodes inside Python applications
10
+
- Examples that showcase streaming updates, file operations, and permission flows
10
11
11
12
## Getting started
12
13
@@ -20,10 +21,10 @@ Welcome to the Python SDK for the Agent Client Protocol (ACP). The package ships
20
21
```
21
22
3. Point your ACP-capable client at the running process (for Zed, configure an Agent Server entry). The SDK takes care of JSON-RPC framing and lifecycle transitions.
22
23
23
-
Prefer a guided tour? Head to the [Quickstart](quickstart.md) for step-by-step instructions, including how to run the agent from an editor or terminal.
24
+
Prefer a guided tour? Head to the [Quickstart](quickstart.md) for terminal, editor, and programmatic launch walkthroughs.
24
25
25
26
## Documentation map
26
27
27
-
-[Quickstart](quickstart.md): install, run, and extend the echo agent
28
+
-[Quickstart](quickstart.md): install, run, and embed the echo agent, plus next steps for extending it
28
29
29
30
Source code lives under `src/acp/`, while tests and additional examples are available in `tests/` and `examples/`. If you plan to contribute, see the repository README for the development workflow.
Inside the context manager the subprocess is monitored, stdin/stdout are tied into ACP, and the
107
-
connection cleans itself up on exit.
88
+
`spawn_agent_process` manages the child process, wires its stdio into ACP framing, and closes everything when the block exits. The mirror helper `spawn_client_process` lets you drive an ACP client from Python as well.
108
89
109
90
## 4. Extend the agent
110
91
@@ -120,4 +101,8 @@ class MyAgent(Agent):
120
101
return PromptResponse(stopReason="end_turn")
121
102
```
122
103
123
-
Hook it up with `AgentSideConnection` inside an async entrypoint and wire it to your client. Refer to [examples/echo_agent.py](https://github.com/psiace/agent-client-protocol-python/blob/main/examples/echo_agent.py) for the complete structure, including lifetime hooks (`initialize`, `newSession`) and streaming responses.
104
+
Hook it up with `AgentSideConnection` inside an async entrypoint and wire it to your client. Refer to:
105
+
106
+
-[`examples/echo_agent.py`](https://github.com/psiace/agent-client-protocol-python/blob/main/examples/echo_agent.py) for the smallest streaming agent
107
+
-[`examples/agent.py`](https://github.com/psiace/agent-client-protocol-python/blob/main/examples/agent.py) for an implementation that negotiates capabilities and streams richer updates
108
+
-[`examples/duet.py`](https://github.com/psiace/agent-client-protocol-python/blob/main/examples/duet.py) to see `spawn_agent_process` in action alongside the interactive client
0 commit comments