Record AutoGen task timeouts
When the AutoGen team stops, record its last approved workflow state and configured timeout. Leave out messages, task text, tool payloads, and free-form stop reasons.
- 1
Team starts
Assign a stable run ID, workflow, team name, and release. Choose the starting state from a fixed list.
- 2
Task flow runs
Keep message and tool details in traces. When the task finishes, record the handoff, tool, and message counts.
- 3
Timeout becomes final
Record timed_out, timeout_ms, and the last approved state. Choose the termination category from a fixed list.
- 4
SQL finds regressions
Compare timeout rate, duration, and handoffs by workflow, team, and release.
Before you start
Before you start
- AutoGen and telemetry-sh initialized in a trusted Python process
- An application-owned run ID and stable team, workflow, model, termination, and release names
- OpenTelemetry export configured separately when detailed AutoGen traces are required
Delivery setup
Install and initialize server-side
Initialize Telemetry for synchronous code or TelemetryAsync for asyncio code once per process with a server-side key. Keep ingestion credentials out of browser bundles, client-visible environment variables, source control, logs, and exception messages.
pip installation
python -m pip install telemetry-sh- 1Create one reusable server-side client. Set its timeout and retry limit.
- 2Log an event when the operation succeeds, fails, retries, or times out.
- 3Send test events with known results and inspect the stored rows before enabling an alert.
Snippet
Start with one structured event
Add this shape where the workflow completes, fails, or retries. Then build the dashboard from real fields.
AutoGen task flow, state, and timeout monitoring event
import asyncio
from time import perf_counter
async def run_agent_team(team, task: str, run_id: str):
started_at = perf_counter()
status = "success"
error_type = None
state_before = "team_started"
state_after = "team_completed"
timeout_ms = 120_000
result = None
try:
result = await asyncio.wait_for(
team.run(task=task),
timeout=timeout_ms / 1000,
)
return result
except TimeoutError:
status = "timed_out"
error_type = "team_timeout"
state_after = "timeout_reached"
raise
except Exception as error:
status = "failed"
error_type = classify_agent_error(error)
state_after = "team_failed"
raise
finally:
await telemetry.log("agent_run_completed", {
"run_id": run_id,
"workflow": "support_resolution",
"team_name": "support_team",
"status": status,
"error_type": error_type,
"state_before": state_before,
"state_after": state_after,
"timeout_ms": timeout_ms,
"timed_out": status == "timed_out",
"termination_reason": getattr(result, "stop_reason", None),
"message_count": len(result.messages) if result else 0,
"duration_ms": round((perf_counter() - started_at) * 1000),
"release": APP_RELEASE,
})Event schema
run_id, workflow, team_name, agent_count, model_alias, termination_reason, and release
status, duration_ms, message_count, tool_call_count, handoff_count, and error_type
state_before, state_after, timeout_ms, timed_out, and termination_reason for bounded task-flow diagnosis
estimated_cost_usd, accepted, human_handoff, evaluation_score, and environment when approved
Check your setup
Checkpoint 1
Wrap the public agent or team run method and send one event when it ends. Add per-message events only when you need them for a specific query.
Checkpoint 2
Record a timeout with its configured duration and the last approved workflow state. A triggered node does not mean the run succeeded.
Checkpoint 3
AutoGen supports OpenTelemetry tracing for detailed agent and tool execution. Keep those traces in an OTLP-compatible backend and correlate the outcome by an approved identifier.
Checkpoint 4
Never emit task text, agent messages, tool arguments, tool results, memory, unrestricted stop messages, or exception text by default.
Verification
Prove the event arrived
Run this after exercising known success and failure cases. Replace the fallback table name if your final event contract differs from the snippet.
AutoGen task flow, state, and timeout monitoring verification query
SELECT *
FROM agent_run_completed
ORDER BY timestamp_utc DESC
LIMIT 20;Implementation references
Review the event contract, data-safety guidance, and upstream primary documentation before enabling a new production path.
Where to log
Keep the outcome event small and recoverable
This pattern provides
- Record the outcome as an event you can query with SQL.
- Stable fields for dashboards, alerts, and cross-event correlation.
- Test events for checking success, failure, retries, and timeouts.
This pattern does not provide
- An OTLP exporter, automatic collection pipeline, or replacement for detailed traces and diagnostic logs.
- Exactly-once delivery merely because the payload contains an event ID.
- Permission to collect raw provider payloads, user content, credentials, or regulated data.
Example event schemas
Event schemas for this workflow
Check what each event records, when to send it, and which field types it needs. Review the example payload and privacy checklist before using it in production.
Use these queries in Telemetry
Learn about AI agent monitoring
Query agent events to compare tool use, model costs, and outcomes for each run.
Related SQL recipes
More SQL recipes
Run the query using this workflow's event fields and check the example result. Save the result to a dashboard or set up an alert.
Reconstruct a correlated workflow timeline
What happened, in order, during the latest failed workflow?
Open recipeDetect repeating AI agent tool loops
Which agent runs appear stuck in a repetitive tool loop?
Open recipeMeasure AI agent task success and human handoff
Which agent workflows finish successfully and produce accepted outcomes?
Open recipeQuery nested AI tool-call events
Which AI tools and arguments are associated with the most failed calls?
Open recipeBrowse by implementation family
Compare related integration patterns
Templates to pair with this integration
AI agent security audit template
Record tool authorization decisions, policy versions, human approvals, and final outcomes. Use selected event fields to keep sensitive payloads out.
Open templateAI agent observability template
Track agent runs, tool calls, retries, latency, errors, and accepted outputs in event tables you can query with SQL.
Open templateMore integrations
CrewAI workflow telemetry
Track CrewAI crew and flow outcomes, task counts, handoffs, retries, latency, cost, and accepted results without retaining agent conversations.
Open guideGoogle ADK agent telemetry
Measure Google Agent Development Kit sessions, run outcomes, tool activity, handoffs, latency, and approved product signals with SQL-ready events.
Open guideClaude Agent SDK telemetry
Track Claude Agent SDK run outcomes, duration, tool activity, turns, cost, and approved product signals without storing prompts or tool payloads.
Open guide