Skip to main content
HQ turns are asynchronous: you post a message, it runs server-side on the agent’s machine, and you watch it unfold over a Server-Sent Events (SSE) stream. This is how you build a live chat UI or react to tool calls and artifacts as they happen.

The flow

1

Create or pick a conversation

Create one against an agent (agent_id from List agents):
2

Open the event stream

Attach to the stream so you don’t miss early events:
-N disables buffering so events print as they arrive.
3

Post a message

The response is immediate; the reply arrives on the stream you opened.

Reading the stream

Each event has a name, an id: cursor, and a one-line JSON payload:
Append text_delta chunks to the active reply; final (or error) ends the turn. The full event vocabulary and scope rules are on Stream conversation events.

In JavaScript

EventSource can’t set an Authorization header, so read the stream with fetch and a streaming body reader (works in Node 18+ and modern browsers):
Track the last id: you saw and send it as the Last-Event-ID header when reconnecting — the server replays what you missed from the journal (or pass ?since_seq=<id> on a fresh attach). Always include an idempotency_key in the message body so a network retry never starts a duplicate turn.

Tips

  • Open the stream early — attach before or right after posting so you catch the first text_delta.
  • One stream, many turnsresult/error ends a turn, not the stream. Keep it open and post again for the next turn.
  • Stop a running turn with Interrupt the active turn.