Skip to main content

Agent Protocol

The Agent Protocol defines how to invoke agents, stream responses, and handle tool invocations via the OpenClaw Gateway API.

Invoke Agent

Send a message to an agent and receive a response.

Method: agent

Request:
string
required
User message to send to the agent
string
required
Session key for conversation context (e.g., "user:alice", "signal:+1234567890")
string
Optional unique run identifier for tracking. Auto-generated if not provided.
string
Target agent ID. Defaults to configured default agent.
string
Override model for this request (e.g., "gpt-4", "claude-opus-4")
string
Thinking budget: "low", "medium", "high", "extended"
boolean
default:false
Whether to deliver the response via configured channel
string
Channel for delivery (e.g., "signal", "telegram", "discord")
string
Recipient identifier (phone, user ID, etc.)
string
Additional system prompt to prepend
number
Request timeout in seconds
Response:
string
Unique run identifier
array
Array of response payloads (text, images, etc.)

Streaming Responses

Agent responses are streamed in real-time via WebSocket events.

Event: agent

Receive agent response chunks during execution.
string
Run identifier matching the request
string
Stream type: "assistant", "tool", "lifecycle"
object
Stream-specific data

Stream Types

assistant - Text response chunks:
tool - Tool invocations:
lifecycle - Execution phases:
Phases: "start", "thinking", "end", "error"

Wait for Agent Response

Wait for a specific agent run to complete.

Method: agent.wait

string
required
Run identifier to wait for
number
default:300
Wait timeout in seconds
Response:

Abort Agent Run

Abort an in-progress agent run.

Method: agent.abort

string
required
Run identifier to abort
Response:

Agent Identity

Get agent metadata and identity information.

Method: agent.identity.get

string
Agent ID. Defaults to default agent.
Response:

List Agents

List all configured agents.

Method: agents.list

Response:

Tool Invocation Events

When the agent invokes tools, you receive real-time events: Tool start:
Tool result:
Tool error:

Example: Complete Agent Invocation

Next Steps

Sessions

Manage conversation sessions

Messages

Send messages via channels

Events

Subscribe to all event types