A Python implement of Agent Client Protocol (ACP, by Zed Industries)
Project description
Agent Client Protocol (Python)
A Python implementation of the Agent Client Protocol (ACP). Use it to build agents that communicate with ACP-capable clients (e.g. Zed) over stdio.
- Package name:
agent-client-protocol(import asacp) - Repository: https://github.com/psiace/agent-client-protocol-python
- Docs: https://psiace.github.io/agent-client-protocol-python/
Install
pip install agent-client-protocol
# or
uv add agent-client-protocol
Development (contributors)
make install # set up venv
make check # lint + typecheck
make test # run tests
Minimal agent example
# agent_main.py
import asyncio
from acp import Agent, AgentSideConnection, Client, InitializeRequest, InitializeResponse, PromptRequest, PromptResponse, SessionNotification, stdio_streams, PROTOCOL_VERSION
from acp.schema import ContentBlock1, SessionUpdate2
class EchoAgent(Agent):
def __init__(self, client: Client) -> None:
self.client = client
async def initialize(self, _p: InitializeRequest) -> InitializeResponse:
return InitializeResponse(protocolVersion=PROTOCOL_VERSION)
async def prompt(self, p: PromptRequest) -> PromptResponse:
text = "".join([getattr(b, "text", "") for b in p.prompt if getattr(b, "type", None) == "text"]) or "(empty)"
await self.client.sessionUpdate(SessionNotification(
sessionId=p.sessionId,
update=SessionUpdate2(sessionUpdate="agent_message_chunk", content=ContentBlock1(type="text", text=f"Echo: {text}")),
))
return PromptResponse(stopReason="end_turn")
async def main() -> None:
reader, writer = await stdio_streams()
AgentSideConnection(lambda c: EchoAgent(c), writer, reader)
await asyncio.Event().wait()
if __name__ == "__main__":
asyncio.run(main())
Run this executable from your ACP-capable client (e.g. configure Zed to launch it). The library takes care of the stdio JSON-RPC transport.
Example: Mini SWE Agent bridge
A minimal ACP bridge for mini-swe-agent is provided under examples/mini_swe_agent. It demonstrates:
- Parsing a prompt from ACP content blocks
- Streaming agent output via
session/update - Mapping command execution to
tool_callandtool_call_update
Documentation
- Quickstart: docs/quickstart.md
- Mini SWE Agent example: docs/mini-swe-agent.md
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file agent_client_protocol-0.0.1.tar.gz.
File metadata
- Download URL: agent_client_protocol-0.0.1.tar.gz
- Upload date:
- Size: 177.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4b6485be9d07d9823d39667b2ac3021ee421035096c4c8a0224cbb91d206b543
|
|
| MD5 |
4007ff7b67b9718a46797395a95103fc
|
|
| BLAKE2b-256 |
5f081c4effe42f1dc24433229f6e51ddca2de24fd27cd43301048beaef528aca
|
File details
Details for the file agent_client_protocol-0.0.1-py3-none-any.whl.
File metadata
- Download URL: agent_client_protocol-0.0.1-py3-none-any.whl
- Upload date:
- Size: 17.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.6.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
25400213dfe2b6b2e5bd00fa441c355fdab093be98ea7362bebd6ef715545673
|
|
| MD5 |
b4919b604d911642a24af7fbff62460b
|
|
| BLAKE2b-256 |
97363f150de0cdb803a4040decd5f48a015fb02d187041e404381206c98e5646
|