Agent Protocol
A standardised protocol for agent-server communication. Implement it in any language to build portable agents.
Overview
The Agent Protocol defines how agents register with a server, receive tasks, and report results. Communication happens over a local channel (in-process for embedded agents) or WebSocket (for standalone agents).
Lifecycle
- Register — agent declares its name, version, and capabilities
- Ready — server acknowledges and grants access to requested resources
- Dispatch — server sends work items when triggers fire
- Result — agent reports task completion (success, failure, or retry)
- Heartbeat — periodic health checks to detect stuck agents
- Shutdown — graceful stop with drain period for in-flight tasks
Message Format
All messages are JSON objects with a type field:
protocol.json
// Agent → Server: register on startup { "type": "register", "agent": "cleanup-agent", "version": "1.0.0", "capabilities": ["database:read", "database:write"] } // Server → Agent: dispatch work { "type": "dispatch", "task_id": "abc-123", "trigger": "schedule", "config": { "retention_days": 30 } } // Agent → Server: report result { "type": "result", "task_id": "abc-123", "status": "success", "data": { "deleted": 42 } }
Message Types
| Type | Direction | Description |
|---|---|---|
register | Agent → Server | Agent announces itself and requests capabilities |
ready | Server → Agent | Server confirms registration and grants resources |
dispatch | Server → Agent | Server sends a task for the agent to execute |
result | Agent → Server | Agent reports task outcome |
heartbeat | Both | Periodic liveness check |
shutdown | Server → Agent | Request graceful stop |
error | Both | Error notification |
Result Statuses
| Status | Description | Server Action |
|---|---|---|
success | Task completed | Mark done, emit completion event |
failure | Task failed permanently | Mark failed, emit error event |
retry | Temporary failure | Re-queue with exponential backoff |
The protocol is transport-agnostic. In-process agents use function calls; standalone agents communicate over WebSocket.