streamChat
streamChat is the chat method on the createAgent(...) result.
Recommended usage
Custom route mode (stream flag)
When stream is false, buffered JSON includes:
chunks: full raw chunk listtext: merged assistant text (text-deltafirst,messagefallback)structured: collectedstructured-datachunks
Buffered helpers (choose one)
Good to know:
collectBufferedStream(...)is built on top ofcollectStream(...), so you still get the full raw chunk list inbuffered.chunks.
Parameters
messages: full chat history for the current turn (required).options.sessionId: optional conversation id for analytics/tracing correlation.options.workflowId: force this request to start in a specific workflow.
Returns
agent.streamChat(...): Promise<AsyncIterable<StreamChunk>>
What happens under the hood
- resolves runtime config and session context
- chooses the workflow (including request-level workflow override)
- builds initial state from input + prior messages
- resumes interrupted flows when resume metadata is present
- runs the workflow graph and streams chunks as SSE
- returns an async stream of
StreamChunkevents
Workflow override per request
When not resuming, options.workflowId can override entry workflow for this request.
Resume behavior
If the last message contains resume metadata, agent.streamChat(...) resumes the interrupted flow automatically.