Skip to main content
Vibes provides two streaming APIs. agent.stream() is the simpler option: it returns a StreamResult that you can iterate over for text tokens and await for the final output. agent.runStreamEvents() gives you granular event-level control: every turn start, text delta, tool call, and tool result is emitted as a typed event. Use agent.stream() for most cases. Reach for agent.runStreamEvents() when you need full observability, custom progress indicators, or real-time tool call logging.

Streaming event timeline

agent.stream() - simple streaming

agent.stream() returns a StreamResult<TOutput> immediately. The async iterables deliver data in real time; the promises resolve when the run completes.
For progressive structured output (only when outputMode: "tool"):

agent.runStreamEvents() - event stream

agent.runStreamEvents() returns an AsyncIterable<AgentStreamEvent<TOutput>>. Switch on event.kind to handle each event type.
The event discriminant is event.kind, not event.type. Always use event.kind when switching on stream events.

AgentStreamEvent reference

When to use which

StreamResult interface

For reference, the complete StreamResult<TOutput> interface:

Messages

Multi-turn conversations and message history

Results

RunResult and StreamResult interfaces