AutoGen AgentChat tracing with Future AGI

Trace an AutoGen AgentChat team in Future AGI using traceAI-autogen.

Trace an AutoGen AgentChat team’s conversation in Future AGI. This guide uses the autogen_agentchat API, not the legacy autogen.UserProxyAgent API.

1. Install

Use Python 3.10–3.13. Install the published AutoGen instrumentor and the OpenAI model-client extra:

pip install "traceAI-autogen==0.2.0" "autogen-agentchat>=0.4.0" "autogen-ext[openai]>=0.4.0"

2. Configure credentials and capture

Set credentials in your shell, not in source code:

export OPENAI_API_KEY="your-openai-api-key"
export FI_API_KEY="your-futureagi-api-key"
export FI_SECRET_KEY="your-futureagi-secret-key"

Warning

Use non-sensitive sample data for this recipe. The AutoGen instrumentor records task text and can record messages, tool data and errors in autogen.* attributes. Do not rely on FI_HIDE_INPUTS or FI_HIDE_OUTPUTS to suppress these integration-specific fields. If your workload requires content suppression, leave AutogenInstrumentor disabled for that workload.

3. Initialize tracing

from fi_instrumentation import register
from fi_instrumentation.fi_types import ProjectType
from traceai_autogen import AutogenInstrumentor

trace_provider = register(
    project_type=ProjectType.OBSERVE,
    project_name="autogen_agents",
)
AutogenInstrumentor().instrument(tracer_provider=trace_provider)

4. Run a short conversation

This example uses a round-robin team with one assistant. It does not configure a code executor or execute model-generated code.

import asyncio
import os

from autogen_agentchat.agents import AssistantAgent
from autogen_agentchat.conditions import MaxMessageTermination
from autogen_agentchat.teams import RoundRobinGroupChat
from autogen_ext.models.openai import OpenAIChatCompletionClient

async def main():
    model_client = OpenAIChatCompletionClient(
        model="gpt-4o",
        api_key=os.environ["OPENAI_API_KEY"],
    )
    try:
        assistant = AssistantAgent(
            name="assistant",
            model_client=model_client,
            system_message="Answer concisely in one sentence.",
        )
        team = RoundRobinGroupChat(
            participants=[assistant],
            termination_condition=MaxMessageTermination(max_messages=2),
        )
        result = await team.run(task="What is the capital of France?")
        print(result.messages[-1].content)
    finally:
        await model_client.close()

try:
    asyncio.run(main())
finally:
    trace_provider.force_flush()
    trace_provider.shutdown()

Choose a model available to your OpenAI account and supported by the AutoGen model client. The instrumentor wraps team operations; it does not guarantee a span for every internal framework operation.

5. View the trace

Open Observe, select autogen_agents, and open the team-run trace to inspect its duration and captured conversation. If a short script exits without exporting its last spans, ensure it flushes the trace provider as shown above.

Was this page helpful?

Questions & Discussion