Skip to content
Integration guide

AutoGen task flow, state, and timeout monitoring

Track AutoGen task-flow state, timeouts, team and agent outcomes, tool activity, handoffs, latency, failures, cost, and releases with compact structured events.

Reviewed by the Telemetry product team on . We checked which events to send, which data to exclude, and how to add the code. Who reviews this page

No credit card is required, and the sample run is created automatically. For a reusable coding-agent workflow, read the agent telemetry skill.md guide.

Useful for
  • AutoGen multi-agent monitoring
  • Task-flow timeout and state-transition monitoring
  • Agent handoff analysis
  • Tool-loop and termination reliability
What to record and check

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. 1

    Team starts

    Assign a stable run ID, workflow, team name, and release. Choose the starting state from a fixed list.

  2. 2

    Task flow runs

    Keep message and tool details in traces. When the task finishes, record the handoff, tool, and message counts.

  3. 3

    Timeout becomes final

    Record timed_out, timeout_ms, and the last approved state. Choose the termination category from a fixed list.

  4. 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.

autogen-install

pip installation

bash
python -m pip install telemetry-sh
  1. 1Create one reusable server-side client. Set its timeout and retry limit.
  2. 2Log an event when the operation succeeds, fails, retries, or times out.
  3. 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

AutoGen task flow, state, and timeout monitoring event

python
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-verification

AutoGen task flow, state, and timeout monitoring verification query

sql
SELECT *
FROM agent_run_completed
ORDER BY timestamp_utc DESC
LIMIT 20;
Confirm one terminal row per logical outcome, with the expected status, identifiers, units, and UTC time.
Inspect the inferred schema and verify that retries do not change field types or generate a new logical event ID.
Search the stored fields for credentials, raw payloads, prompts, private content, and unbounded error messages.
Exercise a provider timeout, ingestion rejection, and process shutdown before treating the dashboard as complete.

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

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.

Browse all recipes

Browse by implementation family

Compare related integration patterns

Templates to pair with this integration

More integrations