Guide

Monitor your AutoGen agents in production.

AutoGen agents converse and call the model many times to reach an answer, and a team that never agrees will keep going until something stops it. Agent Ping instruments the underlying provider and wraps the conversation in a run, so one record carries the cost, the status, why it stopped, and the output.

Two lines, then every run reports in.

Install the SDK and point it at your AutoGen agent. One record lands per run with the cost, status, latency and output behind it.

shellinstall
pip install agentping
pythonmonitor your agent
import agentping

agentping.init(api_key="apk_…", agent="autogen-team")
agentping.instrument_openai()  # or instrument_anthropic()

# Wrap the conversation so the model calls roll up into one run.
with agentping.run(agent="autogen-team") as run:
    result = await team.run(task="…")

AutoGen has no native hook, so you instrument the provider and wrap the conversation; the model calls inside roll up into the run. Full reference is in the docs.

What Agent Ping tracks for AutoGen.

  • Cost per conversation, rolled up across every model call the agents make.
  • Why each conversation stopped, as a run status: success, failed or timeout.
  • A missed-run alert when a scheduled job stops running.
  • Output quality on the final answer, scored against your rubric.

See the pillars behind these: Spend, Pulse and Verify.

Timeouts and termination: know why a conversation stopped.

An AutoGen team runs until a termination condition fires. If none does, it runs until the process dies. The condition that fired is the most useful thing to monitor, and AutoGen hands it to you on every result.

Always set a ceiling

In AgentChat (AutoGen 0.4 and later), termination conditions live in autogen_agentchat.conditions and combine with | (stop when either fires) and & (stop when both have). Pair the condition you hope for, such as TextMentionTermination("APPROVE"), with ceilings that stop a runaway: MaxMessageTermination for message count, TimeoutTermination for wall-clock seconds, and TokenUsageTermination for tokens. RoundRobinGroupChat and SelectorGroupChat also accept max_turns.

Turn the stop reason into a run status

team.run() returns a TaskResult whose stop_reason says which condition fired. Map it onto the run: the condition you wanted is a success, the timeout is a timeout, and hitting the message cap without agreement is a failure. Agent Ping counts timed-out and failed runs against the agent, so an alert rule on failing runs or falling health pages you when the team starts giving up more often.

The hung conversation

A process killed mid-conversation never reports its end. For a scheduled job, set an expected schedule on the agent and Agent Ping raises a missed-run alert when the next run does not arrive. For a long interactive session, use agentping.conversation() with an idle timeout and idle_timeout_status="timeout", and a session that goes quiet is closed as a timeout at its last activity.

pythonmap the stop reason to a run status
from autogen_agentchat.conditions import (
    MaxMessageTermination, TextMentionTermination, TimeoutTermination,
)
from autogen_agentchat.teams import RoundRobinGroupChat

termination = (
    TextMentionTermination("APPROVE")
    | MaxMessageTermination(20)
    | TimeoutTermination(300)
)
team = RoundRobinGroupChat([writer, critic], termination_condition=termination)

with agentping.run(agent="autogen-review", customer_id="acme-corp") as run:
    result = await team.run(task="…")
    reason = result.stop_reason or ""
    if "APPROVE" in reason:
        status = "success"
    elif "Timeout" in reason:
        status = "timeout"
    else:
        status = "failed"  # hit the message cap without agreeing
    run.finish(status=status, output={"stop_reason": reason})

State tracking across turns and resumed runs.

AutoGen keeps conversation state on the team. Agent Ping keeps the record of what happened to it. They are separate jobs, and you want both.

Save and resume in AutoGen

Agents and teams expose async save_state() and load_state(). Save the team after a run, store the dictionary wherever you keep session data, and load it back to resume. Calling team.run() again without a new task continues the previous one.

One record per session, not per resume

If a workflow pauses for a human and resumes later, a fresh agentping.run() per resume splits one piece of work into several records. agentping.conversation() takes a session id you keep with the saved state, so every resume appends its turns to the same run and the cost of the whole session lands in one place.

Record the steps you care about

Model calls arrive automatically from the provider instrumentation. For the AutoGen side, such as which agent spoke, a handoff, or a state checkpoint, append your own event with run.event(). Any event type you send appears in the run timeline as you named it.

Tracking usage: tokens in AutoGen, cost in Agent Ping.

AutoGen tells you how many tokens each message used. It does not tell you what that cost, which customer it was for, or whether last week was higher.

What AutoGen reports

Each agent message in a TaskResult carries models_usage, a RequestUsage with prompt_tokens and completion_tokens. Sum them for a conversation total, or let TokenUsageTermination enforce a hard per-run limit. The task message itself has no usage.

What Agent Ping adds

The provider instrumentation records every model call with its model and token counts, and Agent Ping prices it server side from a maintained rate card. Tag the run with a customer and feature and the spend rolls up that way, with budgets and alerts across runs rather than a cap inside one. There is no need to send the AutoGen totals as well; the instrumented calls are already counted.

Why instrument the provider instead of AutoGen directly?
AutoGen does not expose a callback hook the way LangChain or CrewAI do, so the reliable path is to instrument the model provider (OpenAI, Anthropic) and wrap the conversation in agentping.run(). Every model call inside is attributed to that run.
How do I stop an AutoGen team that runs too long?
Combine your success condition with ceilings using |: MaxMessageTermination, TimeoutTermination and TokenUsageTermination from autogen_agentchat.conditions, or max_turns on the team. Then report the stop_reason on the Agent Ping run, so timeouts show up as timeouts rather than quiet successes.
How do I track token usage in AutoGen?
Each message in the TaskResult has models_usage with prompt and completion tokens. Agent Ping records the same calls through the provider instrumentation and prices them, attributed to the customer and feature you tag on the run.
Does the run capture the whole conversation?
Yes. All the model calls made inside the agentping.run() block roll up into a single run with the combined cost. For a session that is saved and resumed, use agentping.conversation() so every resume lands on the same record.
Will it slow the conversation down?
No. Telemetry runs off the hot path with a hard timeout and a bounded queue.

Monitor your AutoGen agents in minutes.

Add the SDK, send one run, and watch cost, status and quality land in the dashboard.

How to monitor LangGraph agents → How to monitor OpenAI Agents SDK agents → How to monitor CrewAI agents →