Skip to main content
The gateway relays six structured progress events to WebSocket clients once they negotiate the streaming capability, so UIs can paint reasoning, tool progress, and the final answer as they arrive.
The agent emits token, reasoning, and tool events; the gateway forwards each to the WS client, which distinguishes a provisional accepted ack from the final answer.

Quick Start

1

Open a streaming client

2

Print each event type


Event Vocabulary

Each streaming event maps to an EventType in praisonaiagents.gateway.protocols and is advertised in hello_ok.features["events"] when the client negotiates streaming.
reasoning_stream, tool_progress_stream, and stream_error are additive. Existing token_stream consumers keep working unchanged — gate the new events on client.supports_event(...).

Response Frame States

Every WebSocket response frame carries a status: a provisional accepted ack arrives first, then the real answer as final with a structured outcome.
Never treat type: "response" alone as “done”. Check status: "final" and read outcome.status before clearing the spinner.

User Interaction Flow

A streaming UI paints each event as it arrives — reasoning bubble, then a tool progress chip, then the final answer.

Common Patterns


Best Practices

Wrap new-event rendering in client.supports_event("reasoning_stream") and client.supports_event("tool_progress_stream") so legacy gateways — which never advertise these events — degrade silently instead of breaking.
A stream_error frame does not end the run. The gateway may still deliver a final response with outcome.status="error". Surface the error but keep listening until stream_end / final.
Both the provisional ack and the real answer share type: "response". Branch on status: show a spinner on accepted, render only on final, and read outcome.status for the completion state.

Gateway Handshake Protocol

Negotiate streaming and read the advertised event set

Gateway Client

Reconnecting client that streams these events

Frame Codec

Validate inbound frames at the WebSocket boundary

Session Protocol

How sessions carry these events