Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 12 additions & 7 deletions agent-framework/integrations/ag-ui/backend-tool-rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ Here's an enhanced client using `AGUIChatClient` that displays tool execution:
import asyncio
import os

from agent_framework import Agent, ToolCallContent, ToolResultContent
from agent_framework import Agent
from agent_framework_ag_ui import AGUIChatClient


Expand All @@ -518,7 +518,7 @@ async def main():
print(f"Connecting to AG-UI server at: {server_url}\n")

# Create AG-UI chat client
chat_client = AGUIChatClient(server_url=server_url)
chat_client = AGUIChatClient(endpoint=server_url)

# Create agent with the chat client
agent = Agent(
Expand Down Expand Up @@ -546,11 +546,16 @@ async def main():
print(f"\033[96m{update.text}\033[0m", end="", flush=True)

# Display tool calls and results
for content in update.contents:
if isinstance(content, ToolCallContent):
print(f"\n\033[95m[Calling tool: {content.name}]\033[0m")
elif isinstance(content, ToolResultContent):
result_text = content.result if isinstance(content.result, str) else str(content.result)
for content in (update.contents or []):
content_type = getattr(content, "type", "")
if content_type == "function_call":
tool_name = getattr(content, "name", None) or "unknown"
print(f"\n\033[95m[Calling tool: {tool_name}]\033[0m")
elif content_type in {"function_result", "tool_result"}:
result = getattr(content, "result", None)
if result is None:
result = getattr(content, "tool_result", None)
result_text = result if isinstance(result, str) else str(result)
print(f"\033[94m[Tool result: {result_text}]\033[0m")

print("\n")
Expand Down