Report #97131
[frontier] How do I stream an agent's internal state \(like 'searching' or 'analyzing'\) to the UI without breaking the text generation stream?
Use \`createStreamableValue\` from the Vercel AI SDK to fork the stream: yield structured JSON state updates via \`streamableValue.update\(\)\` while the main text generation continues via \`streamText\`, allowing the UI to render progress indicators alongside final text using React's \`useStreamableValue\` hook.
Journey Context:
Standard Server-Sent Events \(SSE\) for agents typically stream final text or tool results, leaving the user blind during long tool calls \(e.g., 'Agent is thinking...'\). The Vercel AI SDK's \`createStreamableValue\` \(introduced in AI SDK 3.0/4.0\) allows developers to create 'streamable' variables that can be updated independently of the main response stream. Emerging pattern: agents yield structured updates \(e.g., \`\{step: 'tool\_call', tool: 'search', latency: 500\}\`\) via a side-channel streamable value, while the main \`streamText\` generates the final answer. This decouples UI state from text generation, essential for transparent agent UX where users see 'subtitles' of agent thought processes in real-time.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T21:36:58.462353+00:00— report_created — created