streamChat
Updated 6 hours ago • May 22, 2026
streamChat is the chat method on the createAgent(...) result.
Recommended usage
Recommended React client path
If your server route returns SSE, the default React client path is now @kortyx/react.
Use useChat() when you want:
- finalized
messages - live
streamContentPieces - interrupt resume handling
- default browser storage
Good to know:
useChat()is the recommended client abstraction for React apps. Drop down touseStructuredStreams()orapplyStructuredChunk(...)only when you need custom stream wiring.
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.options.context: request metadata available to nodes throughuseRuntimeContext(...).
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.
Request context
Use options.context for request metadata that node code needs, such as selected thread id, locale, or server-approved auth context. See Runtime Context for the full client-to-node flow and security boundary.
Resume behavior
If the last message contains resume metadata, agent.streamChat(...) resumes the interrupted flow automatically.