Dosu LogoDosu Logo
Ask
Join our Discord
assistant-ui's SpacePublic
assistant-ui
Documentsassistant-ui's Space
SPEC_AssistantFrame
SPEC_AssistantFrame
Type
External
Status
Published
Created
Mar 17, 2026
Updated
Aug 18, 2026
Updated by
Dosu Bot
Source
packages/react/src/model-context/frame/SPEC_AssistantFrame.md

Assistant Frames#

Assistant frames allow an iframe to provide model context (tools, instructions) to a parent window's assistant.

Scope#

Supported features are:

  • ModelContextProvider API
  • support for tools (defining tool name, description, parameters, execute)
  • support for instructions (system instructions)

Out of scope for now:

  • model configuration (temperature, etc.)
  • ToolCallReader API (incremental reading support)

API design#

SPEC_ModelContextRegistry

Inside the iframe (provides context)#

// Add model context providers
const registry = new ModelContextRegistry();
AssistantFrameProvider.addModelContextProvider(registry);

// Add tools/instructions to registry
registry.addTool({
  toolName: "search",
  description: "Search the web",
  parameters: z.object({ query: z.string() }),
  execute: async (args) => {
    // Tool implementation runs in iframe
    return { results: ["..."] };
  },
});

In the parent window (consumes context)#

// The parent window hosts the assistant that needs the context
const frameHost = new AssistantFrameHost(iframeWindow);

// Register with assistant runtime
const aui = useAui();
aui.modelContext().register(frameHost);

// The assistant now has access to tools from the iframe

Communication Channel Design#

The communication between AssistantFrameProvider (iframe) and AssistantFrameHost (parent window) uses the window.postMessage API with a structured protocol. The iframe provides model context to the parent window's assistant.

ModelContextProvider API#

AssistantFrameHost implements the ModelContextProvider API. It immediately subscribes to the iframe for updates. This is necessary because ModelContextProvider.getModelContext() is synchronous.

Message Channel#

All messages are wrapped with a channel identifier to avoid conflicts with other postMessage usage:

{
  channel: "assistant-ui-frame",
  message: FrameMessage
}

Message Types#

  1. Context Discovery
    • model-context-request: Parent (Host) requests current context from iframe (Provider)
    • model-context-update: Iframe pushes context changes to parent
  2. Tool Execution
    • tool-call: Parent requests tool execution in iframe (where tools are defined)
    • tool-result: Iframe returns execution result or error to parent

Serialization#

  • Tools: Zod schemas are converted to JSON Schema format using z.toJSONSchema()
  • Parameters: Tool parameters are serialized as JSON
  • System messages: Passed as strings
  • Unsupported features: Model config, call settings, and priority are not transmitted

Security Considerations#

  1. Origin Validation: Both sides can specify targetOrigin to restrict message sources; providers share a fail-closed origin policy
  2. Window Reference: Host (parent) only accepts messages from the specific iframe window it's connected to
  3. Message Channel: Using a unique channel identifier prevents cross-talk with other postMessage users

Connection Lifecycle#

  1. Initialization: Parent (Host) sends model-context-request to iframe on creation
  2. Updates: Iframe (Provider) notifies parent whenever any registered ModelContextProvider changes

Error Handling#

  • Tool execution errors are serialized and sent back as error messages
  • Connection failures (timeout, no response) are silently handled - the Host continues to work as an empty ModelContextProvider
  • If the iframe doesn't register any providers, the AssistantFrameHost acts as a no-op empty ModelContextProvider returning {} from getModelContext()
Documents
AG-UI Message History Management
AGENTS
AGENTS
ai-sdk-assistant-ui
CHANGELOG
CHANGELOG
CHANGELOG
README
AG-UI Streaming State Management
AGENTS
ai-sdk-assistant-ui
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
index
README
README
AI SDK Integration
AGENTS
ai-sdk
ai-sdk
assistant-runtime-provider
CHANGELOG
CHANGELOG
form-demo
hooks
index
index
migration
migration
overview
part-2
README
README
README
README
README
README
SKILL
SPEC_AssistantFrame
v4-legacy
v5-legacy
AI SDK Version Compatibility
migration
migration
v4-legacy
v5-legacy
Audio Content Handling
CHANGELOG
CHANGELOG
README
Bedrock Tool Call Streaming
CHANGELOG
Chat History Loading
Chat Transport
AGENTS
ai-sdk
ai-sdk-assistant-ui
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
child-scopes
expo
external-store
form-demo
hooks
index
index
migration
overview
pick-a-runtime
primitives
README
README
README
README
README
README
README
SKILL
SPEC_AssistantFrame
stockbroker
Code Block Rendering
index
markdown
Composer Attachment Handling
attachment
CHANGELOG
CHANGELOG
CHANGELOG
composer
form-demo
index
migration
overview
part-2
perplexity
primitives
primitives
README
README
SKILL
Data Stream Decoding
README
External History Adapter
External Store Adapter
adapters
ai-sdk
external-store
README
sibling-scopes
File Message Part Handling
file
LangChain Message Processing
AGENTS
CHANGELOG
CHANGELOG
CHANGELOG
external-store
migration
part-2
SKILL
LangGraph File Attachments
AGENTS
attachment
CHANGELOG
CHANGELOG
CHANGELOG
external-store
index
primitives
README
LangGraph Runtime API
AGENTS
ai-sdk-assistant-ui
CHANGELOG
CHANGELOG
CHANGELOG
expo
hooks
hooks
index
index
langgraph
migration
overview
pick-a-runtime
README
README
SKILL
Math Delimiter Preprocessing
CHANGELOG
Model Context Provider System
ai-sdk
hooks
model-selector
README
sibling-scopes
Plain Text Stream Encoder
Popover and Command UI Components
chatgpt
claude
grok
modal
model-selector
perplexity
README
SKILL
React Store Notification Manager
quickstart
README
SPEC
why-store
React Version Compatibility
Reasoning Disclosure State Machine
reasoning
SKILL
Remote Thread List Runtime
AGENTS
ai-sdk
hooks
hooks
overview
README
README
README
Resumable Streams
AGENTS
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
child-scopes
Run Cancellation and Abort Signal Propagation
AGENTS
CHANGELOG
CHANGELOG
README
README
Safari Browser Compatibility
CHANGELOG
index
migration
SPEC_AssistantFrame
Shimmer Text Animation
index
StreamdownTextPrimitive
CHANGELOG
Tap React Hook Lifecycle Management
CHANGELOG
child-scopes
methods
quickstart
README
README
why-store
Thread List Runtime API
adapters
ai-sdk
hooks
hooks
langgraph
README
rendering-lists
thread-list
Thread List UI Components
ai-sdk
langgraph
primitives
primitives
rendering-lists
thread-list
Thread Switch Stability
AGENTS
CHANGELOG
CHANGELOG
CHANGELOG
index
primitives
Tool Approval Gates
CHANGELOG
part-3
stockbroker
tool-fallback
Tool Approval Permission Model
CHANGELOG
CHANGELOG
part-3
README
SPEC_AssistantFrame
stockbroker
Tool Call Stream Lifecycle
CHANGELOG
tool-fallback
Top-Anchor Reserve
URL-Based Thread Routing
langgraph
README
SKILL
thread-list
Viewport Auto-Scroll
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CHANGELOG
CLAUDE
CODE_OF_CONDUCT
CONTRIBUTING
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README
README_LANGGRAPH
SECURITY
SPEC_ModelContextRegistry
action-bar
action-bar-more
adapters
api-reference
artifacts
assistant-if
assistant-modal
assistant-modal
assistant-runtime
assistant-sidebar
attachment
attachment-runtime
authorization
branch-picker
composer-runtime
composition
context-display
custom-backend
custom-backend
error
events
heat-graph
image
index
index
index
index
index
index
index
index
introduction
mem0
mermaid
message
message-part
message-part-runtime
message-runtime
message-timing
meta
part-1
part-grouping
quote
scopes
scrollbar
selection-toolbar
simplify-review
sources
state
streamdown
suggestion
syntax-highlighting
thread
thread
thread-list
thread-list-item
thread-list-item-more
thread-list-item-runtime
thread-list-runtime
thread-runtime
tool-group
tw-shimmer