You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: render inline web chat widgets via capability-gated show_widget tool
Adds client-capability-gated tool availability: gateway clients declare
capabilities at connect (new inline-widgets cap), chat.send stamps them into
the run context, and tool assembly drops tools whose requiredClientCaps the
originating client did not declare - so surface-specific tools never appear
on phones, channels, or the CLI. The Canvas plugin ships the first such tool,
show_widget: agents pass SVG or an HTML fragment plus a title; the plugin
hosts it as a bounded, retention-scoped Canvas document and returns the
existing canvas preview handle, which web chat renders as a sandboxed iframe.
Widget iframes carry a per-preview sandbox ceiling (never allow-same-origin,
even under a trusted global embed mode, including the sidebar path), and the
Canvas host serves widget documents with a CSP sandbox header so direct
navigation also runs them in an opaque origin.
Related: #101790
-`inline-widgets`: can render hosted inline widget tool results.
176
+
177
+
Client capabilities describe the connected client, not authorization. Agent tools may declare required capabilities; the Gateway omits those tools unless every requirement appears in the originating client's `caps`. Channel-originated runs have no Gateway client capabilities, so capability-gated tools are unavailable even when tool policy explicitly allows them.
summary: "Render self-contained SVG or HTML widgets inline in web chat"
3
+
title: "Show widget"
4
+
sidebarTitle: "Show widget"
5
+
read_when:
6
+
- You want an agent to render an interactive result inside web chat
7
+
- You need the show_widget input, security, or retention contract
8
+
---
9
+
10
+
`show_widget` renders a self-contained SVG or HTML fragment inline in the Control UI chat transcript. The bundled Canvas plugin owns the tool and hosts each result as a same-origin Canvas document.
11
+
12
+
The tool is available only when the originating Gateway client declares the `inline-widgets` capability. The Control UI declares this capability automatically. Channel runs such as Telegram and WhatsApp do not receive `show_widget`.
13
+
14
+
## Use the tool
15
+
16
+
The agent supplies two required strings:
17
+
18
+
<ParamFieldpath="title"type="string"required>
19
+
Short title shown with the inline preview and in the hosted document title.
Self-contained SVG or HTML fragment. Input beginning with `<svg` after trimming is rendered in SVG mode; all other input is treated as an HTML fragment. Maximum length: 262,144 characters.
24
+
</ParamField>
25
+
26
+
The tool result includes a Canvas preview handle, so web chat renders the widget directly from the tool call and restores it after history reload. Transcripts that do not render previews still show the hosted Canvas path.
27
+
28
+
## Security and storage
29
+
30
+
Widget documents use a restrictive Content Security Policy: inline style and script are allowed, images may use `data:` URLs, and external fetches and resource loads are blocked. Keep all markup, styles, scripts, and image data inside `widget_code`.
31
+
32
+
The iframe always omits `allow-same-origin`, even when the Control UI's global embed mode is `trusted`, so widget scripts cannot read the parent application origin. The Canvas host also serves widget documents with a `Content-Security-Policy: sandbox allow-scripts` response header, so opening the hosted URL directly still runs the widget in an opaque origin instead of the Control UI origin. Browser sandboxing does not prevent a script from navigating its own iframe; only render widget code you are willing to execute in that isolated frame.
33
+
34
+
The iframe also follows [`gateway.controlUi.embedSandbox`](/web/control-ui#hosted-embeds). The default `scripts` tier supports interactive widgets while preserving origin isolation.
35
+
36
+
Canvas retains at most 32 widgets per session (or per agent when no session is available). Creating another widget removes the oldest document in that scope.
Copy file name to clipboardExpand all lines: docs/web/control-ui.md
+2Lines changed: 2 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -328,6 +328,8 @@ Web Push is independent of the iOS APNS relay path (see [Configuration](/gateway
328
328
329
329
Assistant messages can render hosted web content inline with the `[embed ...]` shortcode. The iframe sandbox policy is controlled by `gateway.controlUi.embedSandbox`:
330
330
331
+
The bundled Canvas plugin also provides [`show_widget`](/tools/show-widget) to render self-contained SVG or HTML directly from a tool call. The browser advertises the `inline-widgets` Gateway capability, and the resulting Canvas document remains available when chat history reloads. Channel-originated runs do not receive this tool.
"Render self-contained SVG or HTML inline in web chat. Use for visual or interactive results; external resources are blocked, so inline all required code and data.",
0 commit comments