# Useful but Little-Known Features of OpenAI Agent SDK
🌍 Struggling to keep track of your complex multi-agent setup in your head?
draw_graph lets you visualize your agent architecture as a Graphviz diagram, giving you the full picture at a glance.
📌 Title: Agent Visualization with draw_graph
🔗 URL:
🧩 Overview
Simply call `draw_graph(agent)` to render a Graphviz graph showing the relationships between agents, tools, and handoffs. Agents appear as yellow rectangles, tools as green ellipses, and MCP servers in grey. Handoffs are shown as solid arrows, tool connections as dotted lines, and MCP connections as dashed lines. Use `.view()` to open in a browser or `filename=` to save to a file.
🛠 How to use it
```python
# Install with viz extras
# pip install "openai-agents[viz]"
from agents import Agent, function_tool
from agents.extensions.visualization import draw_graph
@function_tool
def search(query: str) -> str:
return "results"
sub_agent = Agent(name="Researcher", tools=[search])
main_agent = Agent(
name="Coordinator",
handoffs=[sub_agent],
)
# Draw and open in browser
graph = draw_graph(main_agent)
graph.view()
# Save to file
draw_graph(main_agent, filename="agent_graph")
```
🏗 Building it into production
・Auto-generate graphs in CI/CD pipelines and store as documentation artifacts
・Use during code review to visually verify agent configuration changes
・Leverage for onboarding new team members with system architecture overviews
・Compare before/after graphs to detect unintended handoff additions or removals
💡 Use cases
🗺 Auto-generating architecture docs for multi-agent systems
👥 Sharing and reviewing agent configurations across teams
🐛 Detecting circular handoff references or orphaned tools
📊 Creating system diagrams for project proposals
⚠️ Watch out
Requires `pip install "openai-agents[viz]"` for additional dependencies, and the Graphviz binary must also be installed on your system. For very large agent configurations, the resulting graph may become overly complex.
✨ Make your agent architecture visible and understandable with draw_graph.
#
OpenAIAgentSDK# #
AIAgent#