acp-agent-framework 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- acp_agent_framework-0.1.0/.github/workflows/ci.yml +22 -0
- acp_agent_framework-0.1.0/.github/workflows/publish.yml +34 -0
- acp_agent_framework-0.1.0/.gitignore +10 -0
- acp_agent_framework-0.1.0/CONTRIBUTING.md +106 -0
- acp_agent_framework-0.1.0/LICENSE +21 -0
- acp_agent_framework-0.1.0/PKG-INFO +371 -0
- acp_agent_framework-0.1.0/README.md +329 -0
- acp_agent_framework-0.1.0/docs/advanced-features.md +1318 -0
- acp_agent_framework-0.1.0/docs/agents.md +1528 -0
- acp_agent_framework-0.1.0/docs/backends-and-serving.md +1040 -0
- acp_agent_framework-0.1.0/docs/examples-and-cookbook.md +2612 -0
- acp_agent_framework-0.1.0/docs/getting-started.md +818 -0
- acp_agent_framework-0.1.0/docs/images/architecture.png +0 -0
- acp_agent_framework-0.1.0/docs/images/architecture.svg +4 -0
- acp_agent_framework-0.1.0/docs/images/delegation.png +0 -0
- acp_agent_framework-0.1.0/docs/images/internals.png +0 -0
- acp_agent_framework-0.1.0/docs/images/router.png +0 -0
- acp_agent_framework-0.1.0/docs/images/sequential.png +0 -0
- acp_agent_framework-0.1.0/docs/skills.md +750 -0
- acp_agent_framework-0.1.0/docs/tools.md +570 -0
- acp_agent_framework-0.1.0/examples/agent_to_agent/agent.py +69 -0
- acp_agent_framework-0.1.0/examples/function_tools/agent.py +99 -0
- acp_agent_framework-0.1.0/examples/guardrails/agent.py +101 -0
- acp_agent_framework-0.1.0/examples/multi_turn/agent.py +47 -0
- acp_agent_framework-0.1.0/examples/router_agent/agent.py +34 -0
- acp_agent_framework-0.1.0/examples/sequential_pipeline/agent.py +36 -0
- acp_agent_framework-0.1.0/examples/simple_agent/agent.py +11 -0
- acp_agent_framework-0.1.0/examples/streaming/agent.py +36 -0
- acp_agent_framework-0.1.0/examples/tool_agent/agent.py +82 -0
- acp_agent_framework-0.1.0/pyproject.toml +66 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/__init__.py +41 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/agents/__init__.py +7 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/agents/agent.py +114 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/agents/base.py +26 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/agents/router.py +35 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/agents/sequential.py +21 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/agents/tool_agent.py +35 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/backends/__init__.py +3 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/backends/acp_backend.py +186 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/backends/registry.py +39 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/cli.py +288 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/context.py +43 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/events.py +18 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/guardrails.py +25 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/observability.py +149 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/persistence.py +37 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/py.typed +0 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/server/__init__.py +5 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/server/acp_server.py +80 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/server/http_server.py +83 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/server/serve.py +40 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/server/static/index.html +307 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/skills/__init__.py +4 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/skills/loader.py +206 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/skills/skill.py +15 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/state.py +28 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/tools/__init__.py +6 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/tools/agent_tool.py +53 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/tools/base.py +20 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/tools/function_tool.py +38 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/tools/mcp_bridge.py +77 -0
- acp_agent_framework-0.1.0/src/acp_agent_framework/tools/mcp_tool_server.py +66 -0
- acp_agent_framework-0.1.0/tests/__init__.py +0 -0
- acp_agent_framework-0.1.0/tests/conftest.py +0 -0
- acp_agent_framework-0.1.0/tests/integration/__init__.py +0 -0
- acp_agent_framework-0.1.0/tests/integration/test_backends.py +79 -0
- acp_agent_framework-0.1.0/tests/test_acp_backend.py +36 -0
- acp_agent_framework-0.1.0/tests/test_acp_server.py +51 -0
- acp_agent_framework-0.1.0/tests/test_agent_run.py +202 -0
- acp_agent_framework-0.1.0/tests/test_agent_tool.py +90 -0
- acp_agent_framework-0.1.0/tests/test_agents.py +38 -0
- acp_agent_framework-0.1.0/tests/test_backend_registry.py +40 -0
- acp_agent_framework-0.1.0/tests/test_cli.py +27 -0
- acp_agent_framework-0.1.0/tests/test_context.py +45 -0
- acp_agent_framework-0.1.0/tests/test_events.py +21 -0
- acp_agent_framework-0.1.0/tests/test_examples.py +371 -0
- acp_agent_framework-0.1.0/tests/test_guardrails.py +127 -0
- acp_agent_framework-0.1.0/tests/test_http_server.py +57 -0
- acp_agent_framework-0.1.0/tests/test_mcp_bridge.py +87 -0
- acp_agent_framework-0.1.0/tests/test_observability.py +161 -0
- acp_agent_framework-0.1.0/tests/test_persistence.py +41 -0
- acp_agent_framework-0.1.0/tests/test_router.py +59 -0
- acp_agent_framework-0.1.0/tests/test_sequential.py +55 -0
- acp_agent_framework-0.1.0/tests/test_serve.py +18 -0
- acp_agent_framework-0.1.0/tests/test_skill_cli.py +176 -0
- acp_agent_framework-0.1.0/tests/test_skills.py +341 -0
- acp_agent_framework-0.1.0/tests/test_state.py +38 -0
- acp_agent_framework-0.1.0/tests/test_tool_agent.py +96 -0
- acp_agent_framework-0.1.0/tests/test_tools.py +68 -0
- acp_agent_framework-0.1.0/tests/test_web_ui.py +34 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
test:
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
strategy:
|
|
13
|
+
matrix:
|
|
14
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
15
|
+
steps:
|
|
16
|
+
- uses: actions/checkout@v4
|
|
17
|
+
- uses: actions/setup-python@v5
|
|
18
|
+
with:
|
|
19
|
+
python-version: ${{ matrix.python-version }}
|
|
20
|
+
- run: pip install -e ".[dev]"
|
|
21
|
+
- run: ruff check src/ tests/
|
|
22
|
+
- run: pytest tests/ -v
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Publish to PyPI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
release:
|
|
5
|
+
types: [published]
|
|
6
|
+
|
|
7
|
+
permissions:
|
|
8
|
+
contents: read
|
|
9
|
+
id-token: write
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
steps:
|
|
15
|
+
- uses: actions/checkout@v4
|
|
16
|
+
- uses: actions/setup-python@v5
|
|
17
|
+
with:
|
|
18
|
+
python-version: "3.12"
|
|
19
|
+
- run: pip install -e ".[dev]"
|
|
20
|
+
- run: ruff check src/ tests/
|
|
21
|
+
- run: pytest tests/ -v
|
|
22
|
+
|
|
23
|
+
publish:
|
|
24
|
+
needs: test
|
|
25
|
+
runs-on: ubuntu-latest
|
|
26
|
+
environment: pypi
|
|
27
|
+
steps:
|
|
28
|
+
- uses: actions/checkout@v4
|
|
29
|
+
- uses: actions/setup-python@v5
|
|
30
|
+
with:
|
|
31
|
+
python-version: "3.12"
|
|
32
|
+
- run: pip install build
|
|
33
|
+
- run: python -m build
|
|
34
|
+
- uses: pypa/gh-action-pypi-publish@release/v1
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# Contributing to ACP Agent Framework
|
|
2
|
+
|
|
3
|
+
Thanks for your interest in contributing! This guide will help you get started.
|
|
4
|
+
|
|
5
|
+
## Development Setup
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# Clone the repo
|
|
9
|
+
git clone https://github.com/sanjay3290/agentic-framework-acp.git
|
|
10
|
+
cd agentic-framework-acp
|
|
11
|
+
|
|
12
|
+
# Create a virtual environment
|
|
13
|
+
python -m venv .venv
|
|
14
|
+
source .venv/bin/activate
|
|
15
|
+
|
|
16
|
+
# Install with dev dependencies
|
|
17
|
+
pip install -e ".[all]"
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Running Tests
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
# Unit tests
|
|
24
|
+
pytest tests/ -v
|
|
25
|
+
|
|
26
|
+
# Integration tests (requires backends installed)
|
|
27
|
+
pytest tests/ -v -m integration
|
|
28
|
+
|
|
29
|
+
# Lint
|
|
30
|
+
ruff check src/ tests/
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Project Structure
|
|
34
|
+
|
|
35
|
+
- `src/acp_agent_framework/` - Main package
|
|
36
|
+
- `agents/` - Agent implementations (Agent, ToolAgent, SequentialAgent, RouterAgent)
|
|
37
|
+
- `backends/` - ACP backend management (registry, subprocess lifecycle)
|
|
38
|
+
- `server/` - ACP stdio server and HTTP/FastAPI server
|
|
39
|
+
- `tools/` - Tool system (FunctionTool, MCP bridge)
|
|
40
|
+
- `skills/` - Skill loader (agentskills.io spec)
|
|
41
|
+
- `tests/` - Test suite
|
|
42
|
+
- `examples/` - Example agents
|
|
43
|
+
|
|
44
|
+
## Making Changes
|
|
45
|
+
|
|
46
|
+
1. Fork the repo and create a feature branch from `main`
|
|
47
|
+
2. Make your changes
|
|
48
|
+
3. Add or update tests for your changes
|
|
49
|
+
4. Ensure all tests pass: `pytest tests/ -v`
|
|
50
|
+
5. Ensure lint is clean: `ruff check src/ tests/`
|
|
51
|
+
6. Submit a pull request
|
|
52
|
+
|
|
53
|
+
## Code Style
|
|
54
|
+
|
|
55
|
+
- Follow existing patterns in the codebase
|
|
56
|
+
- Use type hints for function signatures
|
|
57
|
+
- Keep modules focused and small
|
|
58
|
+
- Use `ruff` for linting (config in `pyproject.toml`)
|
|
59
|
+
|
|
60
|
+
## Adding a New Backend
|
|
61
|
+
|
|
62
|
+
1. Add entry to `DEFAULT_BACKENDS` in `src/acp_agent_framework/backends/registry.py`
|
|
63
|
+
2. Or register at runtime:
|
|
64
|
+
|
|
65
|
+
```python
|
|
66
|
+
from acp_agent_framework import BackendConfig, BackendRegistry
|
|
67
|
+
|
|
68
|
+
registry = BackendRegistry()
|
|
69
|
+
registry.register("my-backend", BackendConfig(
|
|
70
|
+
command="my-agent-binary",
|
|
71
|
+
args=["--acp"],
|
|
72
|
+
))
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Adding a New Agent Type
|
|
76
|
+
|
|
77
|
+
1. Subclass `BaseAgent` from `src/acp_agent_framework/agents/base.py`
|
|
78
|
+
2. Implement the `run(ctx)` async generator method
|
|
79
|
+
3. Export from `src/acp_agent_framework/__init__.py`
|
|
80
|
+
4. Add tests
|
|
81
|
+
|
|
82
|
+
## Adding Tools
|
|
83
|
+
|
|
84
|
+
Wrap any Python function as a tool:
|
|
85
|
+
|
|
86
|
+
```python
|
|
87
|
+
from acp_agent_framework import FunctionTool
|
|
88
|
+
|
|
89
|
+
def my_tool(query: str) -> str:
|
|
90
|
+
"""Tool description shown to the LLM."""
|
|
91
|
+
return f"Result for {query}"
|
|
92
|
+
|
|
93
|
+
tool = FunctionTool(my_tool)
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
## Reporting Issues
|
|
97
|
+
|
|
98
|
+
Open an issue at https://github.com/sanjay3290/agentic-framework-acp/issues with:
|
|
99
|
+
- What you expected to happen
|
|
100
|
+
- What actually happened
|
|
101
|
+
- Steps to reproduce
|
|
102
|
+
- Python version and OS
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
By contributing, you agree that your contributions will be licensed under the MIT License.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Sanjay
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,371 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: acp-agent-framework
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Build custom ACP-compatible agents using your existing AI subscriptions
|
|
5
|
+
Project-URL: Homepage, https://github.com/sanjay3290/agentic-framework-acp
|
|
6
|
+
Project-URL: Repository, https://github.com/sanjay3290/agentic-framework-acp
|
|
7
|
+
Project-URL: Issues, https://github.com/sanjay3290/agentic-framework-acp/issues
|
|
8
|
+
Author: Sanjay
|
|
9
|
+
License-Expression: MIT
|
|
10
|
+
License-File: LICENSE
|
|
11
|
+
Keywords: acp,agent,framework,llm,mcp
|
|
12
|
+
Classifier: Development Status :: 3 - Alpha
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
|
|
20
|
+
Requires-Python: >=3.10
|
|
21
|
+
Requires-Dist: agent-client-protocol>=0.8.0
|
|
22
|
+
Requires-Dist: click>=8.0
|
|
23
|
+
Requires-Dist: fastapi>=0.100.0
|
|
24
|
+
Requires-Dist: pydantic>=2.0
|
|
25
|
+
Requires-Dist: pyyaml>=6.0
|
|
26
|
+
Requires-Dist: sse-starlette>=1.6.0
|
|
27
|
+
Requires-Dist: uvicorn>=0.20.0
|
|
28
|
+
Provides-Extra: all
|
|
29
|
+
Requires-Dist: httpx>=0.24.0; extra == 'all'
|
|
30
|
+
Requires-Dist: mcp>=1.0; extra == 'all'
|
|
31
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'all'
|
|
32
|
+
Requires-Dist: pytest>=7.0; extra == 'all'
|
|
33
|
+
Requires-Dist: ruff>=0.4.0; extra == 'all'
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: httpx>=0.24.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-asyncio>=0.21; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: ruff>=0.4.0; extra == 'dev'
|
|
39
|
+
Provides-Extra: mcp
|
|
40
|
+
Requires-Dist: mcp>=1.0; extra == 'mcp'
|
|
41
|
+
Description-Content-Type: text/markdown
|
|
42
|
+
|
|
43
|
+
<div align="center">
|
|
44
|
+
|
|
45
|
+
# ACP Agent Framework
|
|
46
|
+
|
|
47
|
+
**Build custom AI agents using your existing subscriptions. No API keys. No vendor lock-in.**
|
|
48
|
+
|
|
49
|
+
[](https://www.python.org/downloads/)
|
|
50
|
+
[](LICENSE)
|
|
51
|
+
[](https://github.com/sanjay3290/agentic-framework-acp/actions/workflows/ci.yml)
|
|
52
|
+
[](https://pypi.org/project/acp-agent-framework/)
|
|
53
|
+
[](https://agentclientprotocol.com/)
|
|
54
|
+
|
|
55
|
+
The first open-source Python framework for building agents that speak the
|
|
56
|
+
[Agent Client Protocol (ACP)](https://agentclientprotocol.com/).
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## How It Works
|
|
63
|
+
|
|
64
|
+
<p align="center">
|
|
65
|
+
<img src="docs/images/architecture.png" alt="Architecture diagram" width="700">
|
|
66
|
+
</p>
|
|
67
|
+
|
|
68
|
+
## Why ACP?
|
|
69
|
+
|
|
70
|
+
| | Traditional Agent Frameworks | ACP Agent Framework |
|
|
71
|
+
|---|---|---|
|
|
72
|
+
| **Auth** | Manage API keys per provider | Use your existing AI subscriptions |
|
|
73
|
+
| **Protocol** | Proprietary APIs, custom integrations | Open standard (ACP) — works with any ACP client |
|
|
74
|
+
| **Lock-in** | Tied to one LLM provider | Swap backends with one line: `backend="gemini"` |
|
|
75
|
+
|
|
76
|
+
## Features
|
|
77
|
+
|
|
78
|
+
| Feature | Description |
|
|
79
|
+
|---|---|
|
|
80
|
+
| **Multi-Backend** | Claude, Gemini, Codex — swap with a single parameter |
|
|
81
|
+
| **Agent Orchestration** | Sequential pipelines, keyword routing, agent-to-agent delegation |
|
|
82
|
+
| **Tool Calling** | Wrap any Python function as an MCP tool the LLM can invoke |
|
|
83
|
+
| **Streaming** | Real-time token-by-token output via async generators |
|
|
84
|
+
| **Multi-Turn** | Conversation history maintained across prompts |
|
|
85
|
+
| **Guardrails** | Input/output validation hooks — redact PII, block injections |
|
|
86
|
+
| **Skills** | Load reusable agent capabilities per [agentskills.io](https://agentskills.io) spec |
|
|
87
|
+
| **Serving** | ACP stdio (editors), HTTP/SSE (web apps), CLI |
|
|
88
|
+
| **Session Persistence** | Save and restore sessions as JSON |
|
|
89
|
+
|
|
90
|
+
## Install
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
pip install acp-agent-framework
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
For development:
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
git clone https://github.com/sanjay3290/agentic-framework-acp.git
|
|
100
|
+
cd agentic-framework-acp
|
|
101
|
+
pip install -e ".[dev]"
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
## Quick Start
|
|
105
|
+
|
|
106
|
+
### Simple Agent
|
|
107
|
+
|
|
108
|
+
```python
|
|
109
|
+
from acp_agent_framework import Agent, serve
|
|
110
|
+
|
|
111
|
+
agent = Agent(
|
|
112
|
+
name="assistant",
|
|
113
|
+
backend="claude", # or "gemini" or "codex"
|
|
114
|
+
instruction="You are a helpful coding assistant.",
|
|
115
|
+
)
|
|
116
|
+
|
|
117
|
+
serve(agent) # Serves over ACP stdio
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
### Sequential Pipeline
|
|
121
|
+
|
|
122
|
+
Chain agents — each one's output feeds into the next:
|
|
123
|
+
|
|
124
|
+
<p align="center">
|
|
125
|
+
<img src="docs/images/sequential.png" alt="Sequential pipeline" width="550">
|
|
126
|
+
</p>
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
from acp_agent_framework import Agent, SequentialAgent, serve
|
|
130
|
+
|
|
131
|
+
researcher = Agent(
|
|
132
|
+
name="researcher",
|
|
133
|
+
backend="claude",
|
|
134
|
+
instruction="Research the given topic thoroughly.",
|
|
135
|
+
output_key="research",
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
summarizer = Agent(
|
|
139
|
+
name="summarizer",
|
|
140
|
+
backend="claude",
|
|
141
|
+
instruction=lambda ctx: f"Summarize:\n\n{ctx.state.get('research', '')}",
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
pipeline = SequentialAgent(name="research-pipeline", agents=[researcher, summarizer])
|
|
145
|
+
serve(pipeline)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Router Agent
|
|
149
|
+
|
|
150
|
+
Route requests to specialists based on keywords:
|
|
151
|
+
|
|
152
|
+
<p align="center">
|
|
153
|
+
<img src="docs/images/router.png" alt="Router agent pattern" width="550">
|
|
154
|
+
</p>
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
from acp_agent_framework import Agent, Route, RouterAgent, serve
|
|
158
|
+
|
|
159
|
+
code_agent = Agent(name="coder", backend="claude", instruction="Help with code.")
|
|
160
|
+
writing_agent = Agent(name="writer", backend="gemini", instruction="Help with writing.")
|
|
161
|
+
|
|
162
|
+
router = RouterAgent(
|
|
163
|
+
name="smart-router",
|
|
164
|
+
routes=[
|
|
165
|
+
Route(keywords=["code", "python", "bug"], agent=code_agent),
|
|
166
|
+
Route(keywords=["write", "essay", "email"], agent=writing_agent),
|
|
167
|
+
],
|
|
168
|
+
default_agent=code_agent,
|
|
169
|
+
)
|
|
170
|
+
|
|
171
|
+
serve(router)
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Custom Tools
|
|
175
|
+
|
|
176
|
+
Wrap Python functions as tools the LLM can invoke via MCP:
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from acp_agent_framework import Agent, FunctionTool, serve
|
|
180
|
+
|
|
181
|
+
def search_docs(query: str) -> str:
|
|
182
|
+
"""Search documentation for a query."""
|
|
183
|
+
return f"Results for: {query}"
|
|
184
|
+
|
|
185
|
+
agent = Agent(
|
|
186
|
+
name="tool-agent",
|
|
187
|
+
backend="claude",
|
|
188
|
+
instruction="Use tools to help the user.",
|
|
189
|
+
tools=[FunctionTool(search_docs)],
|
|
190
|
+
)
|
|
191
|
+
|
|
192
|
+
serve(agent)
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
> Tools are bridged to the backend via MCP — each `FunctionTool` is exposed as an MCP tool that the LLM can call during inference.
|
|
196
|
+
|
|
197
|
+
### ToolAgent (No LLM Needed)
|
|
198
|
+
|
|
199
|
+
For deterministic workflows and data pipelines:
|
|
200
|
+
|
|
201
|
+
```python
|
|
202
|
+
from acp_agent_framework import ToolAgent, FunctionTool, Context
|
|
203
|
+
|
|
204
|
+
async def build_report(ctx, tools):
|
|
205
|
+
data = tools["fetch_data"].run({"source": "api"})
|
|
206
|
+
return tools["format_report"].run({"data": data})
|
|
207
|
+
|
|
208
|
+
agent = ToolAgent(
|
|
209
|
+
name="reporter",
|
|
210
|
+
tools=[FunctionTool(fetch_data), FunctionTool(format_report)],
|
|
211
|
+
execute=build_report,
|
|
212
|
+
output_key="report",
|
|
213
|
+
)
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
### Guardrails
|
|
217
|
+
|
|
218
|
+
Validate and transform inputs/outputs:
|
|
219
|
+
|
|
220
|
+
```python
|
|
221
|
+
from acp_agent_framework import Agent, Guardrail, serve
|
|
222
|
+
|
|
223
|
+
agent = Agent(
|
|
224
|
+
name="safe-agent",
|
|
225
|
+
backend="claude",
|
|
226
|
+
instruction="Be helpful.",
|
|
227
|
+
input_guardrails=[
|
|
228
|
+
Guardrail("pii-redact", lambda t: t.replace("SSN: 123-45-6789", "SSN: [REDACTED]")),
|
|
229
|
+
],
|
|
230
|
+
output_guardrails=[
|
|
231
|
+
Guardrail("length-limit", lambda t: t[:500] + "..." if len(t) > 500 else t),
|
|
232
|
+
],
|
|
233
|
+
)
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
### Agent Skills
|
|
237
|
+
|
|
238
|
+
Load reusable capabilities per the [agentskills.io](https://agentskills.io) spec:
|
|
239
|
+
|
|
240
|
+
```python
|
|
241
|
+
agent = Agent(
|
|
242
|
+
name="chat-agent",
|
|
243
|
+
backend="claude",
|
|
244
|
+
instruction="You are a helpful assistant.",
|
|
245
|
+
skills=["google-chat"], # loads from .agents/skills/google-chat/SKILL.md
|
|
246
|
+
)
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### Streaming
|
|
250
|
+
|
|
251
|
+
Real-time token-by-token output:
|
|
252
|
+
|
|
253
|
+
```python
|
|
254
|
+
agent = Agent(name="storyteller", backend="gemini", instruction="Write stories.", stream=True)
|
|
255
|
+
|
|
256
|
+
async for event in agent.run(ctx):
|
|
257
|
+
if event.type == "stream_chunk":
|
|
258
|
+
print(event.content, end="", flush=True)
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### Agent-to-Agent Delegation
|
|
262
|
+
|
|
263
|
+
Wrap any agent as a tool for another agent:
|
|
264
|
+
|
|
265
|
+
<p align="center">
|
|
266
|
+
<img src="docs/images/delegation.png" alt="Agent-to-agent delegation" width="500">
|
|
267
|
+
</p>
|
|
268
|
+
|
|
269
|
+
```python
|
|
270
|
+
from acp_agent_framework import Agent, AgentTool, serve
|
|
271
|
+
|
|
272
|
+
translator = Agent(name="translator", backend="gemini", instruction="Translate text.")
|
|
273
|
+
summarizer = Agent(name="summarizer", backend="claude", instruction="Summarize text.")
|
|
274
|
+
|
|
275
|
+
manager = Agent(
|
|
276
|
+
name="content-manager",
|
|
277
|
+
backend="claude",
|
|
278
|
+
instruction="Use translator and summarizer tools to help the user.",
|
|
279
|
+
tools=[AgentTool(translator, cwd="."), AgentTool(summarizer, cwd=".")],
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
serve(manager)
|
|
283
|
+
```
|
|
284
|
+
|
|
285
|
+
## Serving Agents
|
|
286
|
+
|
|
287
|
+
| Transport | Use Case | Command |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| **ACP stdio** | ACP-compatible clients | `serve(agent)` |
|
|
290
|
+
| **HTTP/SSE** | Web apps, APIs | `serve(agent, transport="http", port=8000)` |
|
|
291
|
+
| **CLI** | Terminal | `acp-agent run module:agent` |
|
|
292
|
+
|
|
293
|
+
### HTTP Endpoints
|
|
294
|
+
|
|
295
|
+
| Method | Endpoint | Description |
|
|
296
|
+
|---|---|---|
|
|
297
|
+
| `POST` | `/api/sessions` | Create session |
|
|
298
|
+
| `GET` | `/api/sessions/{id}` | Get session info |
|
|
299
|
+
| `DELETE` | `/api/sessions/{id}` | Delete session |
|
|
300
|
+
| `POST` | `/api/sessions/{id}/prompt` | Prompt with SSE streaming |
|
|
301
|
+
|
|
302
|
+
### CLI
|
|
303
|
+
|
|
304
|
+
```bash
|
|
305
|
+
acp-agent init my-agent # Scaffold a new project
|
|
306
|
+
acp-agent run my_agent.agent:agent # Run over ACP stdio
|
|
307
|
+
acp-agent run my_agent.agent:agent -t http -p 8000 # Run as HTTP server
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
## Supported Backends
|
|
311
|
+
|
|
312
|
+
| Backend | Command | Install |
|
|
313
|
+
|---|---|---|
|
|
314
|
+
| **Claude** | `claude-agent-acp` | `npm i -g @zed-industries/claude-agent-acp` |
|
|
315
|
+
| **Gemini** | `gemini --experimental-acp` | `npm i -g @google/gemini-cli` |
|
|
316
|
+
| **Codex** | `codex-acp` | `npm i -g @zed-industries/codex-acp` |
|
|
317
|
+
|
|
318
|
+
Register custom backends:
|
|
319
|
+
|
|
320
|
+
```python
|
|
321
|
+
from acp_agent_framework import BackendConfig, BackendRegistry
|
|
322
|
+
|
|
323
|
+
registry = BackendRegistry()
|
|
324
|
+
registry.register("my-backend", BackendConfig(
|
|
325
|
+
command="my-agent-binary",
|
|
326
|
+
args=["--acp"],
|
|
327
|
+
))
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Architecture
|
|
331
|
+
|
|
332
|
+
<p align="center">
|
|
333
|
+
<img src="docs/images/internals.png" alt="Framework internals" width="700">
|
|
334
|
+
</p>
|
|
335
|
+
|
|
336
|
+
## Testing
|
|
337
|
+
|
|
338
|
+
```bash
|
|
339
|
+
# Unit tests (158 tests)
|
|
340
|
+
pytest tests/ -v
|
|
341
|
+
|
|
342
|
+
# Integration tests (requires backends installed)
|
|
343
|
+
pytest tests/ -v -m integration
|
|
344
|
+
|
|
345
|
+
# Lint
|
|
346
|
+
ruff check src/ tests/
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
## Examples
|
|
350
|
+
|
|
351
|
+
Check the [`examples/`](examples/) directory for complete working agents:
|
|
352
|
+
|
|
353
|
+
| Example | Description |
|
|
354
|
+
|---|---|
|
|
355
|
+
| [`simple_agent`](examples/simple_agent/) | Minimal agent with a single backend |
|
|
356
|
+
| [`function_tools`](examples/function_tools/) | Weather, calculator, and unit converter tools |
|
|
357
|
+
| [`tool_agent`](examples/tool_agent/) | Hacker News digest without an LLM |
|
|
358
|
+
| [`guardrails`](examples/guardrails/) | PII redaction and injection blocking |
|
|
359
|
+
| [`streaming`](examples/streaming/) | Real-time token streaming |
|
|
360
|
+
| [`multi_turn`](examples/multi_turn/) | Conversational agent with history |
|
|
361
|
+
| [`router_agent`](examples/router_agent/) | Keyword-based routing |
|
|
362
|
+
| [`sequential_pipeline`](examples/sequential_pipeline/) | Multi-step agent chain |
|
|
363
|
+
| [`agent_to_agent`](examples/agent_to_agent/) | Manager delegating to specialists |
|
|
364
|
+
|
|
365
|
+
## Contributing
|
|
366
|
+
|
|
367
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for development setup and guidelines.
|
|
368
|
+
|
|
369
|
+
## License
|
|
370
|
+
|
|
371
|
+
[MIT](LICENSE)
|