AutoGen
AutoGen is Microsoft’s framework for building multi-agent applications. You can send full traces of agent runs, tool calls, and large language model (LLM) messages to Logfire.
AutoGen emits native OpenTelemetry spans, which are structured records of agent
creation, agent runs, and tool execution. logfire.configure() installs the application-wide
OpenTelemetry destination, so AutoGen sends those spans to Logfire automatically. AutoGen leaves model-client
tracing to the client library, so logfire.instrument_openai() adds the model
requests and responses made by OpenAIChatCompletionClient.
Install logfire and Microsoft AutoGen:
pip install logfire "autogen-agentchat>=0.7.5" "autogen-ext[openai]>=0.7.5"
import asyncio
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
import logfire
logfire.configure()
logfire.instrument_openai()
async def main():
model_client = OpenAIChatCompletionClient(model='gpt-4o') # needs OPENAI_API_KEY
def lookup_incident(incident_id: str) -> str:
"""Look up the current status and owner of an incident by ID."""
return f'{incident_id} is resolved; owner=platform-observability'
try:
agent = AssistantAgent(
name='assistant',
model_client=model_client,
tools=[lookup_incident],
reflect_on_tool_use=True,
max_tool_iterations=2,
system_message='Use operational tools to verify facts before answering.',
)
result = await agent.run(
task="Use lookup_incident for incident_id='incident-42', then report its status and owner."
)
print(result.messages[-1].content)
finally:
await model_client.close()
asyncio.run(main())
You’ll see the native AutoGen agent run in Live and Agents, with the lookup_incident tool call and
instrumented OpenAI model requests nested beneath it. AutoGen runs also appear in the specialized Agents
view; the support matrix shows which columns each view populates.
Keep your agents’ system messages in Prompt Management and fetch them at runtime with the Logfire software development kit (SDK):
pip install 'logfire[variables]'
from autogen_agentchat.agents import AssistantAgent
from autogen_ext.models.openai import OpenAIChatCompletionClient
from pydantic import BaseModel
import logfire
logfire.configure()
logfire.instrument_openai()
class SystemInputs(BaseModel):
tone: str
system_var = logfire.template_var(
name='prompt__assistant_system',
type=str,
default='You are a helpful assistant.',
inputs_type=SystemInputs,
)
with system_var.get(SystemInputs(tone='friendly'), label='production') as resolved:
system_message = resolved.value
agent = AssistantAgent(
name='assistant',
model_client=OpenAIChatCompletionClient(model='gpt-4o'),
system_message=system_message,
)
See Use Prompts in Your Application for the full workflow.