How It Works
- Agent calls a tool — The backend executes a server-side tool and returns structured data
- Result arrives via SSE — The
tool_resultevent streams back with the tool name and result payload - Widget checks toolRenderers — If a renderer exists for that tool name, it renders your component
- Custom component appears inline — Your chart/table/card renders directly below the tool call status
Setup
1. Define Your Renderers
Create React components that accept{ result, status } props:
2. Pass to the Widget
Renderer Props
Each renderer receives:Renderers are only called when the tool completes successfully (
status === "complete") and the result is not null. You don’t need to check for these conditions.Example: Chart Renderer
Here’s a full example rendering a Recharts line chart from analytics tool results:TypeScript
Import theToolRenderers type for type-safe renderer maps:
Without a Renderer
When notoolRenderers entry exists for a tool, the widget shows the default behavior: a checkmark with the tool name and “done” status. Adding a renderer enhances this — it doesn’t replace the status indicator, it adds your component below it.