Skip to content

Commit 058150e

Browse files
committed
feat: intro mini-swe-agent
1 parent d3b9f3d commit 058150e

File tree

9 files changed

+1838
-57
lines changed

9 files changed

+1838
-57
lines changed

README.md

Lines changed: 27 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,74 +1,52 @@
1-
# agent-client-protocol-python
1+
# Agent Client Protocol - Python SDK
22

3-
[![Release](https://img.shields.io/github/v/release/psiace/agent-client-protocol-python)](https://img.shields.io/github/v/release/psiace/agent-client-protocol-python)
4-
[![Build status](https://img.shields.io/github/actions/workflow/status/psiace/agent-client-protocol-python/main.yml?branch=main)](https://github.com/psiace/agent-client-protocol-python/actions/workflows/main.yml?query=branch%3Amain)
5-
[![codecov](https://codecov.io/gh/psiace/agent-client-protocol-python/branch/main/graph/badge.svg)](https://codecov.io/gh/psiace/agent-client-protocol-python)
6-
[![Commit activity](https://img.shields.io/github/commit-activity/m/psiace/agent-client-protocol-python)](https://img.shields.io/github/commit-activity/m/psiace/agent-client-protocol-python)
7-
[![License](https://img.shields.io/github/license/psiace/agent-client-protocol-python)](https://img.shields.io/github/license/psiace/agent-client-protocol-python)
3+
A Python implementation of the Agent Client Protocol (ACP) used by editors like Zed to talk to external agents over stdio.
84

9-
A Python implement of Agent Client Protocol (ACP, by Zed Industries)
5+
- Repository: https://github.com/psiace/agent-client-protocol-python
6+
- Docs: https://psiace.github.io/agent-client-protocol-python/
107

11-
- **Github repository**: <https://github.com/psiace/agent-client-protocol-python/>
12-
- **Documentation** <https://psiace.github.io/agent-client-protocol-python/>
8+
## What this provides
139

14-
## Getting started with your project
10+
- Typed ACP client/agent primitives (`acp` package under `src/`)
11+
- A runnable example: a bridge that wraps mini-swe-agent as an ACP agent
12+
- Reference implementations under `reference/` for learning and comparison
1513

16-
### 1. Create a New Repository
14+
## Quick start
1715

18-
First, create a repository on GitHub with the same name as this project, and then run the following commands:
19-
20-
```bash
21-
git init -b main
22-
git add .
23-
git commit -m "init commit"
24-
git remote add origin git@github.com:psiace/agent-client-protocol-python.git
25-
git push -u origin main
26-
```
27-
28-
### 2. Set Up Your Development Environment
29-
30-
Then, install the environment and the pre-commit hooks with
16+
Install the development environment:
3117

3218
```bash
3319
make install
3420
```
3521

36-
This will also generate your `uv.lock` file
37-
38-
### 3. Run the pre-commit hooks
39-
40-
Initially, the CI/CD pipeline might be failing due to formatting issues. To resolve those run:
22+
Run quality checks:
4123

4224
```bash
43-
uv run pre-commit run -a
25+
make check
4426
```
4527

46-
### 4. Commit the changes
47-
48-
Lastly, commit the changes made by the two steps above to your repository.
28+
Run tests:
4929

5030
```bash
51-
git add .
52-
git commit -m 'Fix formatting issues'
53-
git push origin main
31+
make test
5432
```
5533

56-
You are now ready to start development on your project!
57-
The CI/CD pipeline will be triggered when you open a pull request, merge to main, or when you create a new release.
34+
## Example: Mini SWE Agent bridge
35+
36+
A minimal ACP bridge for mini-swe-agent is provided under [`examples/mini_swe_agent`](file:///Users/psiace/OSS/agent-client-protocol-python/examples/mini_swe_agent/README.md). It shows how to:
5837

59-
To finalize the set-up for publishing to PyPI, see [here](https://fpgmaas.github.io/cookiecutter-uv/features/publishing/#set-up-for-pypi).
60-
For activating the automatic documentation with MkDocs, see [here](https://fpgmaas.github.io/cookiecutter-uv/features/mkdocs/#enabling-the-documentation-on-github).
61-
To enable the code coverage reports, see [here](https://fpgmaas.github.io/cookiecutter-uv/features/codecov/).
38+
- Parse a prompt from ACP content blocks
39+
- Stream agent output to the client with `session/update`
40+
- Map command execution to `tool_call` and `tool_call_update`
6241

63-
## Releasing a new version
42+
See the example’s README or the docs quickstart for Zed configuration.
6443

65-
- Create an API Token on [PyPI](https://pypi.org/).
66-
- Add the API Token to your projects secrets with the name `PYPI_TOKEN` by visiting [this page](https://github.com/psiace/agent-client-protocol-python/settings/secrets/actions/new).
67-
- Create a [new release](https://github.com/psiace/agent-client-protocol-python/releases/new) on Github.
68-
- Create a new tag in the form `*.*.*`.
44+
## Documentation
6945

70-
For more details, see [here](https://fpgmaas.github.io/cookiecutter-uv/features/cicd/#how-to-trigger-a-release).
46+
- Getting started: [docs/index.md](docs/index.md)
47+
- Quickstart: [docs/quickstart.md](docs/quickstart.md)
48+
- Mini SWE Agent example details: [docs/mini-swe-agent.md](docs/mini-swe-agent.md)
7149

72-
---
50+
## Notes
7351

74-
Repository initiated with [fpgmaas/cookiecutter-uv](https://github.com/fpgmaas/cookiecutter-uv).
52+
- The `reference/` directory contains educational examples and may include optional dependencies. These are not required to use the example bridge.

docs/index.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
# agent-client-protocol-python
22

3-
[![Release](https://img.shields.io/github/v/release/psiace/agent-client-protocol-python)](https://img.shields.io/github/v/release/psiace/agent-client-protocol-python)
4-
[![Build status](https://img.shields.io/github/actions/workflow/status/psiace/agent-client-protocol-python/main.yml?branch=main)](https://github.com/psiace/agent-client-protocol-python/actions/workflows/main.yml?query=branch%3Amain)
5-
[![Commit activity](https://img.shields.io/github/commit-activity/m/psiace/agent-client-protocol-python)](https://img.shields.io/github/commit-activity/m/psiace/agent-client-protocol-python)
6-
[![License](https://img.shields.io/github/license/psiace/agent-client-protocol-python)](https://img.shields.io/github/license/psiace/agent-client-protocol-python)
3+
A Python implementation of the Agent Client Protocol (ACP) used by editors like Zed to talk to external agents over stdio.
74

8-
A Python implement of Agent Client Protocol (ACP, by Zed Industries)
5+
- Quickstart: [quickstart.md](quickstart.md)
6+
- Mini SWE Agent example: [mini-swe-agent.md](mini-swe-agent.md)

docs/mini-swe-agent.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Mini SWE Agent bridge
2+
3+
This example wraps mini-swe-agent behind ACP so Zed can run it as an external agent over stdio.
4+
5+
## Behavior
6+
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+
- Tool calls: when the agent executes a shell command, the bridge sends:
10+
- `tool_call` with `kind=execute`, pending status, and a bash code block containing the command
11+
- `tool_call_update` upon completion, including output and a `rawOutput` object with `output` and `returncode`
12+
- 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+
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+
## Configuration
17+
18+
Environment variables set in the Zed server config control the model:
19+
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
23+
24+
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+
26+
## Files
27+
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)

docs/quickstart.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Quickstart
2+
3+
This repository provides a Python implementation of the Agent Client Protocol (ACP) and a minimal example that bridges mini-swe-agent into an ACP agent.
4+
5+
## Prerequisites
6+
7+
- Python 3.10+
8+
- A virtual environment for this repo (`make install` will create one with uv)
9+
- Zed editor (for running the example agent)
10+
11+
## Install
12+
13+
```bash
14+
make install
15+
```
16+
17+
Run checks:
18+
19+
```bash
20+
make check
21+
```
22+
23+
## Run the Mini SWE Agent bridge in Zed
24+
25+
Install mini-swe-agent into this repo’s venv.
26+
27+
```bash
28+
./.venv/bin/pip install mini-swe-agent
29+
```
30+
31+
Add an agent server to Zed’s `settings.json`:
32+
33+
```json
34+
{
35+
"agent_servers": {
36+
"Mini SWE Agent (Python)": {
37+
"command": "/absolute/path/to/agent-client-protocol-python/.venv/bin/python",
38+
"args": [
39+
"/absolute/path/to/agent-client-protocol-python/examples/mini_swe_agent/agent.py"
40+
],
41+
"env": {
42+
"PYTHONPATH": "/absolute/path/to/agent-client-protocol-python/src",
43+
"MINI_SWE_MODEL": "openrouter/openai/gpt-4o-mini",
44+
"MINI_SWE_MODEL_KWARGS": "{\"api_base\":\"https://openrouter.ai/api/v1\"}",
45+
"OPENROUTER_API_KEY": "sk-or-..."
46+
}
47+
}
48+
}
49+
}
50+
```
51+
52+
In Zed, open the Agents panel and select "Mini SWE Agent (Python)".
53+
54+
For details on behavior and message mapping, see [mini-swe-agent.md](mini-swe-agent.md).

examples/mini_swe_agent/README.md

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Mini SWE Agent (Python) — ACP Bridge
2+
3+
A minimal Agent Client Protocol (ACP) bridge that wraps mini-swe-agent so it can be run by Zed as an external agent over stdio.
4+
5+
## Configure in Zed (using this repo’s venv)
6+
7+
Add an `agent_servers` entry to Zed’s `settings.json`. Point `command` to this repo’s venv Python and `args` to this example script:
8+
9+
```json
10+
{
11+
"agent_servers": {
12+
"Mini SWE Agent (Python)": {
13+
"command": "/absolute/path/to/agent-client-protocol-python/.venv/bin/python",
14+
"args": [
15+
"/absolute/path/to/agent-client-protocol-python/examples/mini_swe_agent/agent.py"
16+
],
17+
"env": {
18+
"PYTHONPATH": "/absolute/path/to/agent-client-protocol-python/src",
19+
"MINI_SWE_MODEL": "openrouter/openai/gpt-4o-mini",
20+
"MINI_SWE_MODEL_KWARGS": "{\"api_base\":\"https://openrouter.ai/api/v1\"}",
21+
"OPENROUTER_API_KEY": "sk-or-..."
22+
}
23+
}
24+
}
25+
}
26+
```
27+
28+
Notes
29+
- `command` must be the absolute path to this repository’s venv Python.
30+
- `args` must point to this example script.
31+
- `PYTHONPATH` must point to this repository’s `src` so the `acp` package can be imported.
32+
- Using OpenRouter:
33+
- Set `MINI_SWE_MODEL` to a model supported by OpenRouter (e.g. `openrouter/openai/gpt-4o-mini`, `openrouter/anthropic/claude-3.5-sonnet`).
34+
- Set `MINI_SWE_MODEL_KWARGS` to a JSON containing `api_base`: `{ "api_base": "https://openrouter.ai/api/v1" }`.
35+
- Set `OPENROUTER_API_KEY` to your API key.
36+
- Alternatively, you can use native OpenAI/Anthropic APIs. Set `MINI_SWE_MODEL` accordingly and provide the vendor-specific API key; `MINI_SWE_MODEL_KWARGS` is optional.
37+
38+
## Requirements
39+
40+
Install mini-swe-agent (or at least its core deps) into this repo’s venv:
41+
42+
```bash
43+
/path/to/.venv/bin/pip install mini-swe-agent
44+
# or: pip install litellm jinja2 tenacity
45+
```
46+
47+
Then in Zed, open the Agents panel and select "Mini SWE Agent (Python)" to start a thread.
48+
49+
## Behavior overview
50+
51+
- User prompt handling
52+
- Text blocks are concatenated into a task and passed to mini-swe-agent.
53+
- Streaming updates
54+
- The agent sends `session/update` with `agent_message_chunk` for incremental messages.
55+
- Command execution visualization
56+
- Each bash execution is reported with a `tool_call` (start) and a `tool_call_update` (complete) including command and output (`returncode` in rawOutput).
57+
- Final result
58+
- A final `agent_message_chunk` is sent at the end of the turn with the submitted output.
59+
60+
Use Zed’s “open acp logs” command to inspect ACP traffic if needed.

0 commit comments

Comments
 (0)