createAgent. These patterns cover everything from basic message rendering to advanced workflows like human-in-the-loop approval and time travel debugging.
Architecture
Every pattern follows the same architecture: acreateAgent backend streams state to a frontend via the useStream hook.
On the backend, createAgent produces a compiled LangGraph graph that exposes a streaming API. On the frontend, the useStream hook connects to that API and provides reactive state — messages, tool calls, interrupts, history, and more — that you render with any framework.
useStream is available for React, Vue, Svelte, and Angular:
Patterns
Render messages and output
Markdown messages
Parse and render streamed markdown with proper formatting and code highlighting.
Structured output
Render typed agent responses as custom UI components instead of plain text.
Reasoning tokens
Display model thinking processes in collapsible blocks.
Generative UI
Render AI-generated user interfaces from natural language prompts using json-render.
Display agent actions
Tool calling
Show tool calls as rich, type-safe UI cards with loading and error states.
Human-in-the-loop
Pause the agent for human review with approve, reject, and edit workflows.
Manage conversations
Branching chat
Edit messages, regenerate responses, and navigate conversation branches.
Message queues
Queue multiple messages while the agent processes them sequentially.
Advanced streaming
Join & rejoin streams
Disconnect from and reconnect to running agent streams without losing progress.
Time travel
Inspect, navigate, and resume from any checkpoint in the conversation history.
Integrations
useStream is UI-agnostic. Use it with any UI component library:
AI Elements
Composable, shadcn/ui-based components —
Conversation, Message, Tool, Reasoning, PromptInput, and more. Components ship as source files you own.assistant-ui
Headless React framework with thread management, message branching, and a ready-to-use
<Thread /> component. Connects via useExternalStoreRuntime.Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

