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
- Featured: Listed as the first third-party SDK on the official ACP site — see https://agentclientprotocol.com/libraries/community
8
9
9
10
## Install
10
11
@@ -24,51 +25,54 @@ make test # run tests
24
25
25
26
## Minimal agent example
26
27
28
+
See a complete streaming echo example in [examples/echo_agent.py](examples/echo_agent.py). It streams back each text block using `session/update` and ends the turn.
29
+
27
30
```python
28
31
import asyncio
29
32
30
33
from acp import (
31
34
Agent,
32
35
AgentSideConnection,
33
-
AuthenticateRequest,
34
-
CancelNotification,
35
36
InitializeRequest,
36
37
InitializeResponse,
37
-
LoadSessionRequest,
38
38
NewSessionRequest,
39
39
NewSessionResponse,
40
40
PromptRequest,
41
41
PromptResponse,
42
+
SessionNotification,
42
43
stdio_streams,
43
44
)
45
+
from acp.schema import ContentBlock1, SessionUpdate2
This example wraps mini-swe-agent behind ACP so Zed can run it as an external agent over stdio.
3
+
> Just a show of the bridge in action. Not a best-effort or absolutely-correct implementation of the agent.
4
+
5
+
This example wraps mini-swe-agent behind ACP so Zed can run it as an external agent over stdio. It also includes a local Textual UI client connected via a duet launcher
4
6
5
7
## Behavior
6
8
7
-
- Prompts: text blocks are concatenated into a single task string; referenced resources (`resource_link` / `resource`) are surfaced as hints in the task.
8
-
- Streaming: incremental text is sent via `session/update`with`agent_message_chunk`.
9
+
- Prompts: text blocks are concatenated into a single task string. (Resource embedding is not used in this example.)
10
+
- Streaming: only LM output is streamed via `session/update`→`agent_message_chunk`.
9
11
- Tool calls: when the agent executes a shell command, the bridge sends:
10
12
-`tool_call` with `kind=execute`, pending status, and a bash code block containing the command
11
13
-`tool_call_update` upon completion, including output and a `rawOutput` object with `output` and `returncode`
12
14
- Final result: on task submission (mini-swe-agent prints `COMPLETE_TASK_AND_SUBMIT_FINAL_OUTPUT` as the first line), a final `agent_message_chunk` with the submission content is sent.
13
15
14
-
Non-terminating events (e.g. user rejection or timeouts) are surfaced both as a `tool_call_update` with `status=cancelled|failed` and as a text chunk so the session can continue.
15
-
16
16
## Configuration
17
17
18
-
Environment variables set in the Zed server config control the model:
18
+
Environment variables control the model:
19
19
20
20
-`MINI_SWE_MODEL`: model ID (e.g. `openrouter/openai/gpt-4o-mini`)
21
-
-`MINI_SWE_MODEL_KWARGS`: JSON string of extra parameters (e.g. `{ "api_base": "https://openrouter.ai/api/v1" }`)
22
-
- Vendor API keys (e.g. `OPENROUTER_API_KEY`) must be present in the environment
21
+
-`OPENROUTER_API_KEY` for OpenRouter; or `OPENAI_API_KEY` / `ANTHROPIC_API_KEY` for native providers
22
+
- Optional `MINI_SWE_MODEL_KWARGS`: JSON, e.g. `{ "api_base": "https://openrouter.ai/api/v1" }` (auto-injected for OpenRouter if missing)
23
+
24
+
Agent behavior automatically maps the appropriate API key based on the chosen model and available environment variables.
23
25
24
26
If `mini-swe-agent` is not installed in the venv, the bridge attempts to import a vendored reference copy under `reference/mini-swe-agent/src`.
25
27
28
+
## How to run
29
+
30
+
- In Zed (editor integration): configure an agent server to launch `examples/mini_swe_agent/agent.py` and set the environment variables there. Use Zed’s “Open ACP Logs” to inspect `tool_call`/`tool_call_update` and message chunks.
31
+
- In terminal (local TUI): run the duet launcher to start both the agent and the Textual client with the same environment and dedicated pipes:
32
+
33
+
```bash
34
+
python examples/mini_swe_agent/duet.py
35
+
```
36
+
37
+
The launcher loads `.env` from the repo root (using python-dotenv) so both processes share the same configuration.
- In Human mode, you’ll be prompted for a bash command; it will be executed and streamed back as a tool call.
43
+
- Each executed command appears in the “TOOL CALLS” section with live status and output.
44
+
26
45
## Files
27
46
28
-
- Example entry: [`examples/mini_swe_agent/agent.py`](https://github.com/psiace/agent-client-protocol-python/blob/main/examples/mini_swe_agent/agent.py)
0 commit comments