Streaming
“Streaming” in Shiro means seeing the run while it is still moving. Provider token deltas are one signal. Tool starts, approval waits, handoffs, and completion events are equally important — and they are what Studio timelines are built from.
Why this is broader than provider streaming#
If you only stream model text, operators miss:
- which tool is hanging
- that an approval is blocking progress
- that a handoff changed the active agent
Subscribe to the engine’s event bus / TraceManager, or open Studio while developing.
Observing events#
import { Engine, ShiroEventType, TraceManager } from "@shiro-sdk/core";
const traces = new TraceManager();
const engine = new Engine({ events: traces });
// Execute as usual — exporters and Studio consume the same event stream.
await engine.execute(agent, input);Provider adapters may also implement stream() for token-level deltas. Use that for UI typing
effects; use runtime events for operational truth.
When to care#
| Need | Prefer |
|---|---|
| Live operator view | Studio + runtime events |
| Chat typing indicator | Provider stream deltas |
| Progress in a CLI | Event types → terminal lines |
| Long tool calls | Tool started/finished events |
Best practices#
- Render event types differently from text deltas
- Keep
runIdon every UI update - Treat approval waits as first-class states
- Do not assume the first event is model text
Common mistakes#
- Streaming provider text only and calling the run “observable”
- Hiding tool failures until the final message
- Dropping run ids from client events