Events
Real-time events emitted by Agent Platform that you can subscribe to via WebSocket.
WebSocket Connection
Connect to the WebSocket endpoint to receive real-time events for a specific thread.
Connect to WebSocket
const ws = new WebSocket(
"wss://agent-platform.example.com/ws/threads/{threadId}"
);
ws.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log(data.event_type, data);
};Event Types
The following events are emitted during agent conversations.
| Field | Type | Description |
|---|---|---|
| typing_started | signal | Agent has started generating a response |
| text_delta | stream | Incremental text chunk from the agent's response |
| stream_end | signal | Agent has finished streaming the current response |
| message_completed | signal | Full message has been saved to the database |
| tool_call_started | signal | Agent is invoking a tool |
| tool_call_completed | signal | Tool execution finished (success or failure) |
| approval_pending | signal | A tool call requires human approval |
| approval_expired | signal | An approval timed out or was rejected |
| escalation_created | signal | Agent escalated to another agent or human |
| conversation_started | signal | A new conversation workflow has started |
| conversation_completed | signal | Conversation workflow finished |
| conversation_failed | signal | Conversation workflow failed with an error |
Event Payloads
typing_started
{
"event_type": "typing_started",
"agent_id": "ops-triage",
"thread_id": "550e8400-e29b-41d4-a716-446655440000",
"workflow_id": "agent-conv-550e8400-a1b2c3d4"
}text_delta
{
"event_type": "text_delta",
"agent_id": "ops-triage",
"thread_id": "550e8400-e29b-41d4-a716-446655440000",
"content": "I'll look up the account details"
}tool_call_started
{
"event_type": "tool_call_started",
"thread_id": "550e8400-e29b-41d4-a716-446655440000",
"workflow_id": "agent-conv-550e8400-a1b2c3d4",
"tool_call_id": "call_abc123",
"tool_name": "lookup_account",
"preview": {
"email": "user@example.com"
}
}tool_call_completed
{
"event_type": "tool_call_completed",
"thread_id": "550e8400-e29b-41d4-a716-446655440000",
"workflow_id": "agent-conv-550e8400-a1b2c3d4",
"tool_call_id": "call_abc123",
"tool_name": "lookup_account"
}message_completed
{
"event_type": "message_completed",
"agent_id": "ops-triage",
"thread_id": "550e8400-e29b-41d4-a716-446655440000",
"message_id": "msg-abc123",
"content": "I found the account. The customer's subscription is active..."
}