Guide
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.
Install the SDK and point it at your AutoGen agent. One record lands per run with the cost, status, latency and output behind it.
pip install agentping
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.
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.
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.
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.
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.
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})
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.
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.
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.
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.
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.
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.
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.
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 →