Agent Streaming Protocol
A protocol for AI agent sessions with durable message streaming and resumable connections.
What is Agent Streaming Protocol?
The Agent Streaming Protocol enables AI agent interactions over HTTP with full resumability. Unlike traditional WebSocket-based chat, sessions survive disconnections - clients can reconnect and replay any missed messages from the exact point they left off.
Built on top of Unbroken Protocol, it combines:
- Claude Agent SDK for AI model interaction
- Unbroken Protocol for message persistence
- SSE for real-time streaming
Key Features
| Feature | Description |
|---|---|
| Resumable | Reconnect and continue from any point |
| Persistent | Full conversation history preserved |
| Tool Use | Stream tool calls and results |
| Web Native | Works in browsers via SSE |
Architecture
┌─────────────────────────────────────────────────────────────┐│ Client ││ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││ │ Message │ │ Tool │ │ Offset │ ││ │ Input │ │ Executor │ │ Storage │ ││ └──────┬──────┘ └──────┬──────┘ └──────┬──────┘ │└─────────┼──────────────────┼──────────────────┼─────────────┘ │ POST │ POST │ ▼ ▼ │┌─────────────────────────────────────────────────────────────┐│ Agent Server ││ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ││ │ Claude │◀───│ Session │───▶│ Durable │ ││ │ API │ │ Manager │ │ Stream │ ││ └─────────────┘ └─────────────┘ └─────────────┘ │└─────────────────────────────────────────────────────────────┘Quick Example
# Create a sessioncurl -X PUT http://localhost:9999/agent/my-chat \ -H "Content-Type: application/json" \ -d '{"model": "claude-sonnet-4-5-20250929"}'
# Stream messages (SSE)curl "http://localhost:9999/agent/my-chat?offset=-1&live=sse"
# Send a promptcurl -X POST http://localhost:9999/agent/my-chat/prompt \ -H "Content-Type: application/json" \ -d '{"content": [{"type": "text", "text": "Hello!"}]}'Protocol at a Glance
Endpoints
| Method | Path | Description |
|---|---|---|
PUT | /agent/{id} | Create session |
GET | /agent/{id}?offset=X&live=sse | Stream messages |
POST | /agent/{id}/prompt | Send user message |
POST | /agent/{id}/tool-result | Submit tool result |
POST | /agent/{id}/cancel | Cancel current turn |
DELETE | /agent/{id} | End session |
HEAD | /agent/{id} | Check session exists |
Headers
| Header | Direction | Description |
|---|---|---|
Stream-Next-Offset | Response | Offset for resumption |
Stream-Up-To-Date | Response | At end of messages |
SSE Event Types
| Event | Description |
|---|---|
user | User message sent to agent |
assistant | Agent response text |
tool_use | Agent requests tool execution |
tool_result | Tool result submitted |
turn_complete | Turn finished with stop reason |
error | Error occurred |
control | Stream metadata/offset |
Use Cases
- AI Assistants: Persistent chat with tool use
- Code Agents: Autonomous coding with file/terminal tools
- Workflows: Long-running AI tasks with checkpoints
- Multi-client: Share agent sessions across devices
Specification
For the complete protocol specification, see PROTOCOL.md.
Default Port
The agent server uses port 9999/tcp by default (same as Unbroken Protocol).
Requirements
- Server: Bun runtime,
ANTHROPIC_API_KEYenvironment variable - Client: Any HTTP client (browser, curl, custom)