Documentation
AutoGen Integration
Track Microsoft AutoGen multi-agent conversations with automatic message tracking and tool executions.
What Gets Tracked Automatically
Agent Messages
All agent-to-agent communications.
Tool Calls
Function and tool executions.
Model Responses
LLM responses with token usage.
Cost & Tokens
Estimated costs based on model.
Installation
# For AutoGen 0.4+ (recommended)
pip install guardy autogen-agentchat>=0.4.0
# For legacy pyautogen
pip install guardy pyautogen>=0.2.0AutoGen 0.4+ (autogen-agentchat)
from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient
from guardy import GuardyClient
from guardy.autogen import GuardyAutogenHandler
# Initialize
client = GuardyClient(api_key="guardy_live_xxx")
session_id = client.create_session(
name="Code Review Team",
agent_name="autogen-review",
user_id="user_123"
)
# Create handler
handler = GuardyAutogenHandler(client, session_id, verbose=True)
# Create model client
model_client = OpenAIChatCompletionClient(model="gpt-4o")
# Create agents
reviewer = AssistantAgent(
name="CodeReviewer",
model_client=model_client,
system_message="You review code for bugs.",
)
security = AssistantAgent(
name="SecurityExpert",
model_client=model_client,
system_message="You analyze security vulnerabilities.",
)
# Create team
team = RoundRobinGroupChat(
participants=[reviewer, security],
max_turns=4,
)
# Run with tracking
result = await handler.run_team(team, task="Review this code...")
# Finish
handler.finish(success=True)Legacy pyautogen
from autogen import AssistantAgent, UserProxyAgent
from guardy import GuardyClient
from guardy.autogen import GuardyAutogenHandler
client = GuardyClient(api_key="guardy_live_xxx")
session_id = client.create_session(
name="AutoGen Chat",
agent_name="autogen-chat",
user_id="user_123"
)
handler = GuardyAutogenHandler(client, session_id)
# Create agents
assistant = AssistantAgent("assistant", llm_config=llm_config)
user_proxy = UserProxyAgent("user_proxy")
# Register for tracking
handler.register_agents([assistant, user_proxy])
# Chat
user_proxy.initiate_chat(assistant, message="Hello!")
handler.finish(success=True)