Skip to main content
AutoGen AgentChat is Microsoft’s open-source framework for building multi-agent AI applications. It supports single agents with tools, multi-agent Swarms with handoffs, and model-based speaker selection via SelectorGroupChat. HoneyHive integrates with AutoGen through the OpenInference AutoGen AgentChat instrumentor, which captures agent-level spans including agent names, tool calls, handoffs, and model requests.
Add tracing in 3 lines of code. Initialize HoneyHiveTracer, call AutogenAgentChatInstrumentor().instrument(tracer_provider=tracer.provider), and all agent runs, tool calls, and handoffs are automatically traced.

Quick Start

To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see Tracer Initialization.
Order matters. Call HoneyHiveTracer.init(...) before instrumentor.instrument(...), and instrument before creating agents.

What Gets Traced

The AutoGen AgentChat instrumentor captures:
  • Agent runs - Every agent.run() and team .run() call with inputs and outputs
  • LLM calls - Model requests via OpenAIChatCompletionClient.create with messages, responses, and token usage
  • Tool executions - Each tool call with arguments and results
  • Agent handoffs - Delegation between agents in Swarm and SelectorGroupChat teams

Example 1: Single Agent with Tools

A single agent handling customer support queries with tool calls and multi-turn conversation history.

Example 2: Multi-Agent Swarm with Handoffs

A Swarm team where a triage agent delegates to specialists. Handoffs are automatically traced.
In HoneyHive, you’ll see the full trace hierarchy: triage agent → handoff → order specialist → tool call → handoff back → final response.

Example 3: SelectorGroupChat

A team where a model selects the best agent to speak next, useful for complex queries requiring multiple specialists.

Example 4: @trace Decorator for Custom Logic

Use the @trace decorator to create parent spans that wrap agent calls with your own business logic. This groups the agent invocation and any surrounding processing into a single span visible in HoneyHive.
In HoneyHive, the escalation_workflow span appears as a parent containing the agent run, LLM calls, and tool calls nested underneath.
Use @trace when you need a parent span that groups agent calls with pre/post-processing logic (validation, routing, response formatting). For simple agent runs, the instrumentor’s automatic spans are sufficient.

Troubleshooting

Traces not appearing

  • Ensure HoneyHiveTracer.init(...) is called before instrumentor.instrument(...).
  • Pass tracer_provider=tracer.provider to instrument() so AutoGen uses HoneyHive’s tracer provider.
  • Ensure HH_API_KEY and OPENAI_API_KEY are set.
  • Call tracer.force_flush() before your process exits to ensure all spans are exported.

Only seeing OpenAI spans, not agent spans

Make sure you’re using openinference-instrumentation-autogen-agentchat (not openinference-instrumentation-openai). The AutoGen-specific instrumentor captures agent-level spans (agent names, handoffs, tool calls) in addition to underlying model calls.

Enrich Traces

Add user IDs and custom metadata to your spans.

Custom Spans

Create spans for business logic around agent calls.

Distributed Tracing

Trace agents across service boundaries.

Query Trace Data

Export traces programmatically.

Resources