Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Spin up a working ACP agent/client loop in minutes. Keep this page beside the te

- Python 3.10–3.14 with `pip` or `uv`
- An ACP-capable client such as Zed (recommended for validation)
- Optional: the Gemini CLI (`gemini --experimental-acp`) for the bridge example
- Optional: the Gemini CLI (`gemini --acp`; use `--experimental-acp` for older versions) for the bridge example

## Step 1 — Install the SDK

Expand Down Expand Up @@ -145,7 +145,7 @@ Run it with `run_agent()` inside an async entrypoint and wire it to your client.
- [`examples/echo_agent.py`](https://github.com/agentclientprotocol/python-sdk/blob/main/examples/echo_agent.py) for the smallest streaming agent
- [`examples/agent.py`](https://github.com/agentclientprotocol/python-sdk/blob/main/examples/agent.py) for an implementation that negotiates capabilities and streams richer updates
- [`examples/duet.py`](https://github.com/agentclientprotocol/python-sdk/blob/main/examples/duet.py) to see `spawn_agent_process` in action alongside the interactive client
- [`examples/gemini.py`](https://github.com/agentclientprotocol/python-sdk/blob/main/examples/gemini.py) to drive the Gemini CLI (`--acp`) directly from Python
- [`examples/gemini.py`](https://github.com/agentclientprotocol/python-sdk/blob/main/examples/gemini.py) to drive the Gemini CLI (`--acp`; use `--experimental-acp` for older versions) directly from Python

Need builders for common payloads? `acp.helpers` mirrors the Go/TS helper APIs:

Expand Down
12 changes: 10 additions & 2 deletions examples/gemini.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,8 @@ async def run(argv: list[str]) -> int: # noqa: C901
*cmd,
stdin=asyncio.subprocess.PIPE,
stdout=asyncio.subprocess.PIPE,
stderr=None,
# Suppress Gemini CLI diagnostic noise unless debugging
stderr=None if args.debug else asyncio.subprocess.DEVNULL,
)
except FileNotFoundError as exc:
print(f"Failed to start Gemini CLI: {exc}", file=sys.stderr)
Expand Down Expand Up @@ -412,6 +413,10 @@ def _print_request_error(stage: str, err: RequestError) -> None:
async def _shutdown(proc: asyncio.subprocess.Process, conn: ClientSideConnection) -> None:
with contextlib.suppress(Exception):
await asyncio.wait_for(conn.close(), timeout=2)
if proc.stdin is not None:
with contextlib.suppress(Exception):
proc.stdin.close()
await asyncio.wait_for(proc.stdin.wait_closed(), timeout=2)
if proc.returncode is None:
proc.terminate()
try:
Expand All @@ -424,7 +429,10 @@ async def _shutdown(proc: asyncio.subprocess.Process, conn: ClientSideConnection

def main(argv: list[str] | None = None) -> int:
args = sys.argv if argv is None else argv
return asyncio.run(run(list(args)))
try:
return asyncio.run(run(list(args)))
except KeyboardInterrupt:
return 1


if __name__ == "__main__":
Expand Down
Loading