showcase/shell-docs/src/content/docs/integrations/agno/generative-ui/tool-rendering.mdx
<IframeSwitcher id="backend-tools-example" exampleUrl="https://feature-viewer.copilotkit.ai/agno/feature/backend_tool_rendering?sidebar=false&chatDefaultOpen=false" codeUrl="https://feature-viewer.copilotkit.ai/agno/feature/backend_tool_rendering?view=code&sidebar=false&codeLayout=tabs" exampleLabel="Demo" codeLabel="Code" height="700px" />
<Callout> This example demonstrates the [implementation](#implementation) section applied in the{" "} <a href="https://feature-viewer.copilotkit.ai/langgraph/feature/agentic_chat" target="_blank" > CopilotKit feature viewer </a> . </Callout>Tools are a way for the LLM to call predefined, typically, deterministic functions. CopilotKit allows you to render these tools in the UI as a custom component, which we call Generative UI.
Rendering tools in the UI is useful when you want to provide the user with feedback about what your agent is doing, specifically when your agent is calling tools. CopilotKit allows you to fully customize how these tools are rendered in the chat.
<Tabs groupId="language_agno_agent" items={['Python']} default="Python" persist> <Tab value="Python"> ```python title="agent.py" from agno.agent import Agent from agno.models.openai import OpenAIChat from agno.tools import tool # ...
# [!code highlight:6]
@tool
def get_weather(location: str):
"""
Get the weather for a given location.
"""
return f"The weather for {location} is 70 degrees."
# ...
agent = Agent(
model=OpenAIChat(id="gpt-5.4"),
tools=[get_weather], # [!code highlight]
description="A helpful assistant that can answer questions and provide information.",
instructions="Be helpful and friendly. Format your responses using markdown where appropriate.",
)
```
</Tab>
// ...
const YourMainContent = () => {
// ...
{
/* [!code highlight:12] */
}
useRenderTool({
name: "get_weather",
render: ({ status, args }) => {
return (
<p className="text-gray-500 mt-2">
{status !== "complete" && "Calling weather API..."}
{status === "complete" &&
`Called the weather API for ${args.location}.`}
</p>
);
},
});
// ...
};
Try asking the agent to get the weather for a location. You should see the custom UI component that we added render the tool call and display the arguments that were passed to the tool.
</Step> </Steps>