Skip to Content

How do I see every tool call in an agent built with AutoGen?

Rius shows every tool call in an AutoGen agent as an execute_tool span, which the framework emits itself, so you add no wrapper around your tools. You add one observe wrapper on the entrypoint so each unit of work becomes one trace. Open the trace in the console to read each tool call inside its agent run, or search the Spans tab for execute_tool to list them all.

How it works

AutoGen (AgentChat, Python) emits its own OpenTelemetry spans through the global tracer provider, which rius.init() installs. Rius records these on its own:

  • Agent construction: a create_agent span named after the agent.
  • Agent runs: an invoke_agent span named after the agent.
  • Tool calls: an execute_tool span named after the tool, one for each call.
  • Model calls: a ChatCompletion generation with model, tokens and cost, captured by the openai integration because AutoGen’s model client goes through the OpenAI client.

What you add yourself is one observe wrapper on the function that starts the work. It becomes the root span of the trace and groups agent creation and invocation under it.

Do not wrap your AutoGen tool functions with observe. AutoGen executes tools in a detached context, so the wrapper’s span cannot find the run and splits off as its own single-span trace. The framework’s execute_tool spans already cover every tool call.

There is no AutoGen integration for TypeScript today. This guide covers the Python framework. For the full list of supported frameworks, see Integrations.

Set it up

  1. Install the SDK with the openai extra, plus AutoGen. The extra installs the instrumentation, not the OpenAI library itself.
pip install "glassflow-rius[openai]" "autogen-agentchat" "autogen-ext[openai]"
  1. Call rius.init() once, then wrap your entrypoint with observe and the agent span kind. Pass your tool as a plain function in tools, with no decorator of your own. Here lookup stands for your own code.
import rius from autogen_agentchat.agents import AssistantAgent from autogen_ext.models.openai import OpenAIChatCompletionClient from rius import SpanKind rius.init(api_key="ri_...", service_name="my-agent") def account_status(email: str) -> str: """Fetch a customer's account standing by email.""" return lookup(email) @rius.observe(name="handle-ticket", kind=SpanKind.AGENT) async def handle_ticket(ticket: str) -> str: agent = AssistantAgent( name="support_agent", model_client=OpenAIChatCompletionClient(model="gpt-5-mini"), tools=[account_status], system_message="Answer support questions; check accounts with the tool.", ) result = await agent.run(task=ticket) return str(result.messages[-1].content)
  1. Run one request that makes the agent call a tool. The AutoGen integration page has the full recipe and the runnable example behind it.

  2. Open Traces in the console and select the trace. Check that the root span, the invoke_agent span, the execute_tool span and the ChatCompletion generation are all there. See Exploring traces for the views.

  3. To scope a whole conversation, wrap each run in rius.session() and reuse your conversation id, so one conversation reads as one session.

What you get

A run that calls a tool looks like this in the waterfall (a real trace from the example, autogen-agentchat 0.7.5):

handle-ticket AGENT 2.8s ├─ create_agent support_agent 0ms └─ invoke_agent support_agent 2.8s ├─ ChatCompletion LLM 2.6s └─ execute_tool account_status 0ms

Where to look:

  • Waterfall view: each tool call sits under the invoke_agent span that made it, next to the model call that asked for it. LLM spans show their token counts inline. Repeated calls of a tool that failed and were retried collapse into one N attempts row on the trace page. Successful repeats stay separate rows.
  • Spans tab: this lists individual spans instead of whole traces. Its search box matches span names, so typing execute_tool finds the tool calls across all your traces. Use the status filter and the time range to narrow them down.
  • Span detail: select a tool span to read its timing and its Raw attributes. Use the previous and next buttons, or j and k, to step through spans one at a time.
  • Model section: the ChatCompletion generation shows model, tokens and cost. Costs are list-price estimates in US dollars.

Three quirks to know when reading these traces:

  • Framework spans arrive with status UNSET rather than OK on success. The trace status still reads Ok.
  • Generation spans share the generic name ChatCompletion, so tell them apart by position in the tree.
  • If you wrap a tool with observe anyway, it appears as its own one-span trace, separate from the run.

For the wider picture of watching agents after launch, see Monitor AI agents in production.

When something else fits

If your AutoGen tools are not called through the framework, for example a helper you call directly from your own code, the framework emits no execute_tool span for it. Use the tracing page for how to record such a function yourself. If you build agents in TypeScript, there is no AutoGen integration, so trace those calls with manual spans as described on the Integrations page.

Still stuck? Get help

Last updated on