Streaming

With stream: true, execAgent answers with newline-delimited JSON: one object per line, written as the run produces it.

The stream

The response has content type application/x-ndjson. Each line is a JSON object with a type and, for most types, a value:

typevalueWhen
progressA short stringEach progress command, as it runs.
dataOne output part: text, html or imageEach part the agent appends to its output, including the streamed text of an llm command.
tracetraceType, and a value with path, duration and messageOnly on validateDraftStream: the execution trace, one line per event.
agentThe same object a non-streaming call returns, without outputOnce, when the run ends. Carries resultCode, convid and askInput.
noopnoneA heartbeat while nothing else is happening, so that proxies keep the connection open. The interval is the stream heartbeat in Runtime limits.
endnoneThe last line.
A streamed run
{"type": "progress", "value": "Looking up the forecast"}
{"type": "data", "value": {"contentType": "text", "text": "Tomorrow in Boston: "}}
{"type": "data", "value": {"contentType": "text", "text": "sunny, high of 24°C."}}
{"type": "agent", "value": {"success": true, "resultCode": "success", "convid": "…", "agentName": "weather"}}
{"type": "end"}

Assemble the output by appending the data parts in order. Read resultCode and askInput from the agent line; an ask is answered exactly as in a non-streaming call.

Stopping a run

Closing the connection stops the agent. The run is recorded with the result code stopped, and the conversation keeps the state it had before the run. The GUI's stop button does nothing more than this.

When to stream

Stream when a person is watching: the first output appears as soon as the agent produces it, and progress messages show that a long call is still working. Do not stream from a scheduler or a pipeline step; a single response is simpler to handle and carries the whole output.