Skip to content

Commit 1ca902c

Browse files
authored
docs: add default tool rendering guide (CopilotKit#2717)
Signed-off-by: Tyler Slaton <[email protected]>
1 parent 07a346d commit 1ca902c

File tree

3 files changed

+45
-0
lines changed

3 files changed

+45
-0
lines changed

docs/content/docs/langgraph/generative-ui/backend-tools.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Accordions, Accordion } from "fumadocs-ui/components/accordion";
77
import { IframeSwitcher } from "@/components/content"
88
import { Tabs, Tab } from "fumadocs-ui/components/tabs"
99
import RunAndConnect from "@/snippets/integrations/langgraph/run-and-connect.mdx"
10+
import DefaultToolRendering from "@/snippets/shared/guides/default-tool-rendering.mdx"
1011

1112
<IframeSwitcher
1213
id="backend-tools-example"
@@ -146,3 +147,7 @@ render the tool call and display the arguments that were passed to the tool.
146147

147148
</Step>
148149
</Steps>
150+
151+
## Default Tool Rendering
152+
153+
<DefaultToolRendering components={props.components} />

docs/content/docs/microsoft-agent-framework/generative-ui/backend-tools.mdx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ description: Render your agent's tool calls with custom UI components.
55
---
66
import { Accordions, Accordion } from "fumadocs-ui/components/accordion";
77
import { IframeSwitcher } from "@/components/content"
8+
import DefaultToolRendering from "@/snippets/shared/guides/default-tool-rendering.mdx"
89

910
{/* TODO: Swap these links for Microsoft Agent Framework links once Microsoft Agent Framework is officially added to the feature viewer */}
1011
<IframeSwitcher
@@ -114,3 +115,7 @@ render the tool call and display the arguments that were passed to the tool.
114115

115116
</Step>
116117
</Steps>
118+
119+
## Default Tool Rendering
120+
121+
<DefaultToolRendering components={props.components} />
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
`useDefaultTool` provides a catch-all renderer for **any tool** that doesn't have a specific `useRenderToolCall` defined. This is useful for:
2+
3+
- Displaying all tool calls during development
4+
- Rendering MCP (Model Context Protocol) tools
5+
- Providing a generic fallback UI for unexpected tools
6+
7+
```tsx title="app/page.tsx"
8+
import { useDefaultTool } from "@copilotkit/react-core"; // [!code highlight]
9+
// ...
10+
11+
const YourMainContent = () => {
12+
// ...
13+
// [!code highlight:15]
14+
useDefaultTool({
15+
render: ({ name, args, status, result }) => {
16+
return (
17+
<div style={{ color: "black" }}>
18+
<span>
19+
{status === "complete" ? "" : ""}
20+
{name}
21+
</span>
22+
{status === "complete" && result && (
23+
<pre>{JSON.stringify(result, null, 2)}</pre>
24+
)}
25+
</div>
26+
);
27+
},
28+
});
29+
// ...
30+
}
31+
```
32+
33+
<Callout type="info">
34+
Unlike `useRenderToolCall`, which targets a specific tool by name, `useDefaultTool` catches **all** tools that don't have a dedicated renderer.
35+
</Callout>

0 commit comments

Comments
 (0)