Tulip Logo IconTulip
Recipes

Tool Renderers

Give a tool call its own card in the chat.

Tool renderers make demos and production assistants easier to understand.

The default card

A tool without a renderer gets a ToolCallCard with the tool's title from tool() and an icon for its kind: a search icon for reads, a pencil for writes, a trash can for deletes. Write titles in the app's language: users also see them on the Agents page and in MCP clients.

export const searchCrmRecords = tool({
  name: "search_crm_records",
  title: "CRM records zoeken",
  kind: "read",
  // ...
});

Add a renderer only when a tool needs its own card:

  • AI SDK tools without a Tulip title, such as a provider's web search
  • tools whose output deserves more than the default card

Define a renderer

"use client";

import { ToolCallCard, type ToolRenderer } from "@tulip-systems/ai/chat/client";
import { Search } from "lucide-react";

export const webSearchRenderer: ToolRenderer = {
  toolName: "web_search",
  render: (part) => (
    <ToolCallCard part={part} title="Internetzoekopdracht" icon={<Search className="size-3.5" />} />
  ),
};

A renderer is a plain object: the name the model calls the tool by, and a render that gets the tool part (ToolChatPart). ToolCallCard takes the part, and optionally a title, an icon and a className. Render your own component instead when the output deserves more; useChatThread() tells it whether the assistant is still responding.

Share renderers

Centralize tool renderers near the chat configuration:

/**
 * Tools with their own card. Every other tool gets the default card with its title.
 */
export const ASSISTANT_TOOL_RENDERERS = [webSearchRenderer];

Then pass them to the thread once:

<ChatThread status={chat.status} toolRenderers={ASSISTANT_TOOL_RENDERERS}>

Translate the cards' texts with labels on the same ChatThread (see Labels).

Guidance

  • Keep server tools out of the renderer; it only needs the tool's name.
  • Start with the default card, and add a renderer only when a tool needs more.
  • Render important mutation tools more clearly than background read tools.
  • Keep renderers stable and reusable across full-page chat and sidepanel chat.

On this page