Open Agent Protocol — a routing layer for inter-agent task handoff
Project description
OAP — Open Agent Protocol
A lightweight routing layer for passing tasks between AI agents.
OAP defines a standard envelope format (TaskEnvelope) and a router that dispatches tasks to the right agent based on capabilities or explicit handoff instructions.
Installation
pip install open-agent-protocol
Quick start
from oap import TaskEnvelope, OAPRouter
from oap.adapters.http import HTTPAdapter
router = OAPRouter()
router.register(
"research-agent",
HTTPAdapter(agent_id="research-agent", base_url="http://localhost:9000"),
capabilities=["research", "search", "find"],
)
envelope = TaskEnvelope(goal="research the best vector databases")
result = await router.route(envelope)
print(result.memory["last_result"])
CLI
# Create a new task envelope
oap init "research the best vector databases" --output task.json
# Register an HTTP agent — OAP discovers capabilities automatically from GET /
oap register research-agent http://localhost:9000
# Falls back to manual capabilities if the agent has no GET / endpoint
oap register research-agent http://localhost:9000 --capabilities "research,search,find"
# Route the envelope to the best matching agent
oap route task.json --output result.json
# Automatically follow handoffs until the task is complete
oap chain task.json --output final.json
# Inspect an envelope
oap inspect result.json
# Validate envelope structure
oap validate result.json
# List all registered agents
oap agents
# Remove an agent from the registry
oap unregister research-agent
Chaining agents
When an agent sets a handoff.next_agent on its response, oap chain automatically routes to the next agent and keeps going until the task is complete or a hop limit is reached.
# Python API
result, visited = await router.chain(envelope, max_hops=10)
print(" → ".join(visited)) # e.g. research-agent → summarise-agent
# CLI — follows handoffs automatically, prints each hop
oap chain task.json --output final.json --max-hops 5
The chain stops when:
- An agent returns a response with no
handoffset, or max_hopsis reached (default: 10)
Registry
Agents are stored in ~/.oap/agents.json and persist across commands.
When an agent implements GET / returning {agent_id, capabilities, description}, registration is automatic:
oap register my-agent http://localhost:9000
# → OAP hits GET /, reads capabilities and description, saves everything
oap register my-agent http://localhost:9000 --capabilities "research,find"
# → fallback: use provided capabilities if GET / is unavailable
oap agents # list all registered agents with description column
oap ping # health-check all agents, auto-updates capabilities if changed
oap unregister my-agent
Agent health endpoint
Add GET / to your agent to enable self-registration and health checks:
@app.get("/")
async def info():
return {
"agent_id": "my-agent",
"capabilities": ["research", "find", "search"],
"description": "Researches topics and returns structured findings.",
"status": "ok",
}
Concepts
- TaskEnvelope — the standard task object passed between agents. Contains the goal, memory, steps taken, and optional constraints.
- OAPRouter — selects the best registered agent for a given envelope and invokes it.
- AgentAdapter — translates between the envelope format and an agent's native interface.
- HTTPAdapter — built-in adapter for agents that expose a
POST /invokeendpoint.
License
MIT
Project details
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 open_agent_protocol-0.2.3.tar.gz.
File metadata
- Download URL: open_agent_protocol-0.2.3.tar.gz
- Upload date:
- Size: 18.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
30b3cb35f5b086b1b9fcbfd01a134b9001cccfddf3b27c7aecf73934485773e0
|
|
| MD5 |
ef9fb9a43d288f3883a652f627e40a69
|
|
| BLAKE2b-256 |
dd0030174274d697bcc4411e48766e5c9a5a152f4f33d34d6beba208869c928d
|
File details
Details for the file open_agent_protocol-0.2.3-py3-none-any.whl.
File metadata
- Download URL: open_agent_protocol-0.2.3-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6a20b5ad942b2fb995c60040c5d8cdb4fd35fe0843fc1e4f8a538c5fc499cc9b
|
|
| MD5 |
45f1fe7f8b5bdf51474cf6dc2cb5cde7
|
|
| BLAKE2b-256 |
fa5570bcd9922f50f6ddc1c779212302d80d66c9ca0dd36993648133d4defc33
|