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.

FieldTypeDescription
typing_startedsignalAgent has started generating a response
text_deltastreamIncremental text chunk from the agent's response
stream_endsignalAgent has finished streaming the current response
message_completedsignalFull message has been saved to the database
tool_call_startedsignalAgent is invoking a tool
tool_call_completedsignalTool execution finished (success or failure)
approval_pendingsignalA tool call requires human approval
approval_expiredsignalAn approval timed out or was rejected
escalation_createdsignalAgent escalated to another agent or human
conversation_startedsignalA new conversation workflow has started
conversation_completedsignalConversation workflow finished
conversation_failedsignalConversation 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..."
}