Skip to content

Add onRichContent callback - #912

Merged
giannagerton merged 2 commits into
mainfrom
gianna/rich-content-pr-1
Aug 11, 2026
Merged

Add onRichContent callback#912
giannagerton merged 2 commits into
mainfrom
gianna/rich-content-pr-1

Conversation

@giannagerton

@giannagerton giannagerton commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds an experimental onRichContent callback so the SDK can hand off agent-driven UI components (e.g. an item card) to whoever's consuming it.

  • New RichContentClientEvent/RichContentData schema in @elevenlabs/types (AsyncAPI + generated types)
  • onRichContent callback in @elevenlabs/client, dispatched from BaseConversation the same way every other server-pushed event is — no reply sent back, the agent's turn doesn't wait on it
  • Re-exported through @elevenlabs/react's HookCallbacks

Backs the embedded widget, which is the only client the server sends components to today — this callback won't fire for other consumers yet. props is agent-authored; treat it as untrusted when rendering.

Summary

RFC

Adds an experimental onRichContent callback so the SDK can hand off agent driven UI to the widget.

  • New RichContentClientEvent/RichContentData schema in @elevenlabs/types
  • onRichContent callback in @elevenlabs/client, dispatched from BaseConversation. No reply sent back, the agent's turn doesn't wait on it
  • Re-exported through @elevenlabs/react's HookCallbacks

Note

Medium Risk
New experimental surface that forwards untrusted props to app code; misuse when rendering could introduce XSS, but core conversation and auth paths are unchanged.

Overview
Adds rich_content to the agent WebSocket contract and wires it through @elevenlabs/types, @elevenlabs/client, and @elevenlabs/react as an experimental onRichContent callback.

When the server sends a display component (e.g. item_card), the client invokes the callback with { rich_content_id, component, props, event_id }. Unlike client_tool_call, the SDK does not send a response, so the agent turn is not blocked on the client.

BaseConversation dispatches rich_content in onMessage via handleRichContent; tests cover payload forwarding, no sendMessage, and missing callback. The changeset notes props should be treated as agent-authored and untrusted when rendering into a document.

Reviewed by Cursor Bugbot for commit a9b4b67. Bugbot is set up for automated code reviews on this repo. Configure here.

giannagerton commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

@giannagerton
giannagerton force-pushed the gianna/rich-content-pr-1 branch from e30bbbb to 0659a44 Compare August 3, 2026 17:09
@giannagerton giannagerton changed the title rich content pr 1 [agents] add onRichContent callback Aug 3, 2026
@giannagerton giannagerton changed the title [agents] add onRichContent callback Add onRichContent callback Aug 4, 2026
@giannagerton
giannagerton marked this pull request as ready for review August 4, 2026 14:23
@giannagerton
giannagerton force-pushed the gianna/rich-content-pr-1 branch from 0659a44 to a9b4b67 Compare August 4, 2026 17:58
@giannagerton
giannagerton requested a review from kamilk-11 August 11, 2026 01:02
Removed unnecessary comments from onRichContent API documentation.
@giannagerton
giannagerton merged commit 93cf08c into main Aug 11, 2026
5 checks passed
@giannagerton
giannagerton deleted the gianna/rich-content-pr-1 branch August 11, 2026 18:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants