Skip to content
Blog

Building an Automated Incident Triage Workflow with ADK 2.0 Graphs

An end-to-end ADK 2.0 graph tutorial that ingests an alert, enriches it with tools, runs LLM severity analysis, and conditionally pages, logs, or auto-resolves — with deterministic routing for on-call safety.

Published on • December 2, 2026

AI Assistant

At 3 a.m., the difference between a good on-call tool and a bad one is not how clever the model is — it is whether the routing is predictable. An LLM can look at an alert and say “this is critical,” but if the code that decides whether to page a human is also hidden inside a prompt, you have no reviewable guarantee that a critical alert becomes a page. You have a hope.

ADK 2.0’s graph workflows exist precisely to split those concerns. Let the model do what models are good at — interpreting messy alert text, estimating blast radius, summarizing for humans — and let a plain Python router plus a conditional edge do what code does best: dispatch deterministically, with a default branch for everything the classifier botched.

In this tutorial you will build a complete incident triage graph: ingest → enrich (tools) → LLM severity analysis → conditional route (page / log / auto-resolve) → notification, then examine why this shape is safer for on-call than a monolithic prompt.

Prerequisites

  • ADK 2.0 installed (pip install google-adk) and an API key configured
  • Read: graph-based workflows and graph routes
  • Comfort with Pydantic models and Python functions
  • Optional: a PagerDuty/Slack webhook URL for the notification node

1. The graph at a glance

            ┌────────────────────────────────────────────────────────┐
  START ───▶│ ingest_alert → enrich_alert → analyze_severity → router│
            └────────────────────────────────────────────────────────┘
                                       router
                    ┌────────────────────┼────────────────────┐
              "PAGE"▼              "LOG" ▼         "AUTO_RESOLVE"▼
          ┌──────────────┐   ┌──────────────┐   ┌──────────────────┐
          │ page_oncall  │   │   log_only   │   │  auto_resolve    │
          └──────────────┘   └──────────────┘   └──────────────────┘
                    (each handler calls the shared notification helper)

Four node types, four jobs: two deterministic functions that parse and enrich, one LLM agent that classifies, and one pure function that dispatches. Every branch target performs its action and notifies through the same helper, so the user-facing outcome is uniform no matter which route fired.

2. Ingest and enrich: deterministic front matter

The first node receives the raw alert payload as its input. Parsing is code, not a model:

import json

from google.adk import Event, Workflow
from pydantic import BaseModel


class Alert(BaseModel):
    source: str
    service: str
    metric: str
    value: float
    threshold: float
    message: str


def ingest_alert(node_input: str) -> Event:
    """Parse the raw webhook payload. No model on this path."""
    payload = json.loads(node_input)
    alert = Alert(
        source=payload.get("source", "unknown"),
        service=payload["service"],
        metric=payload["metric"],
        value=float(payload["value"]),
        threshold=float(payload["threshold"]),
        message=payload.get("message", ""),
    )
    return Event(output=alert)

The second node enriches with tools — runbook lookups and recent-deploy history. Tools in ADK are plain functions with docstrings; here the node calls them directly, which keeps enrichment deterministic and cheap:

def lookup_runbook(service: str) -> dict:
    """Fetch the runbook and escalation policy for a service from the CMDB."""
    return RUNBOOKS.get(service, {"runbook": None, "escalation": "default"})


def fetch_recent_deploys(service: str) -> list[dict]:
    """Return the last 5 deployments for a service."""
    return DEPLOY_CLIENT.recent(service, limit=5)


async def enrich_alert(node_input: Alert) -> Event:
    """Attach context before the model ever sees the alert."""
    yield Event(message=f"Enriching alert for {node_input.service}...")
    enriched = {
        "alert": node_input.model_dump(),
        "runbook": lookup_runbook(node_input.service),
        "recent_deploys": fetch_recent_deploys(node_input.service),
    }
    yield Event(output=enriched)

Note the yield Event(message=...): a progress line for whoever is watching the run, with no effect on the graph’s data flow. Exactly one output follows — the one-output-per-execution rule holds.

3. LLM severity analysis: the model classifies

The only non-deterministic node is the analysis agent, and it is constrained on both ends with schemas:

from typing import Literal

from google.adk import Agent
from pydantic import BaseModel


class SeverityAssessment(BaseModel):
    service: str
    severity: Literal["CRITICAL", "HIGH", "LOW"]
    affected_users: int
    rationale: str


analyze_severity = Agent(
    name="analyze_severity",
    model="gemini-flash-latest",
    mode="single_turn",
    output_schema=SeverityAssessment,   # predecessor's output arrives as input
    instruction="""
        You are an incident triage analyst. Given an alert with its runbook
        and recent deployment history, decide severity:
        - CRITICAL: user-facing outage, data loss risk, or paging threshold met
        - HIGH: degraded service, no full outage
        - LOW: noisy or informational
        Estimate affected_users from the metric value. Be conservative:
        when unsure between two levels, choose the lower one.
        Reply only with the JSON object.
    """,
)

output_schema forces the model to answer in exactly that shape, so the router downstream receives a validated SeverityAssessment — not a paragraph it has to parse. mode="single_turn" is the default for agents inside a graph: they consume the node’s input rather than conversational history.

4. Conditional routing: code decides who gets paged

The router is a pure function. It never “returns the next node” — it returns a value, and the edge dictionary decides where that value goes:

from google.adk.workflow import DEFAULT_ROUTE


def router(node_input: SeverityAssessment) -> Event:
    """Deterministic dispatch: the model classified, code routes."""
    if node_input.severity == "CRITICAL" and node_input.affected_users >= 100:
        return Event(route="PAGE", output=node_input)
    if node_input.severity in ("CRITICAL", "HIGH"):
        return Event(route="LOG", output=node_input)
    return Event(route="AUTO_RESOLVE", output=node_input)

The dispatch table is data, reviewable in a diff:

root_agent = Workflow(
    name="incident_triage_workflow",
    edges=[
        ("START", ingest_alert, enrich_alert, analyze_severity, router),
        (router, {
            "PAGE": page_oncall,
            "LOG": log_only,
            "AUTO_RESOLVE": auto_resolve,
            DEFAULT_ROUTE: log_only,   # classifier botched a value: fail safe
        }),
    ],
)

DEFAULT_ROUTE matches whenever no other branch on the router matched. Treat it as mandatory — classifiers fail in production in ways happy-path tests never anticipate, and an exhaustive default degrades into a known handler instead of a runtime dispatch error.

5. Branch handlers and the notification node

Each branch performs its action and notifies through one shared helper, so the three outcomes stay consistent:

def send_notification(channel: str, assessment: SeverityAssessment) -> None:
    """Post to PagerDuty, Slack, or the incident log — the single notify path."""
    NOTIFIERS[channel].send(
        severity=assessment.severity,
        service=assessment.service,
        summary=assessment.rationale,
    )


def page_oncall(node_input: SeverityAssessment) -> Event:
    send_notification("pagerduty", node_input)
    return Event(message=f"PAGED on-call: {node_input.rationale}")


def log_only(node_input: SeverityAssessment) -> Event:
    send_notification("incident_log", node_input)
    return Event(message=f"Logged ({node_input.severity}): {node_input.rationale}")


def auto_resolve(node_input: SeverityAssessment) -> Event:
    send_notification("incident_log", node_input)
    return Event(message=f"Auto-resolved: {node_input.rationale}")

Three practical constraints from the graph engine shape this design:

  1. Only one branch runs, so a JoinNode cannot converge them — a join waits for all predecessors and would hang. Sharing a notification helper inside the handlers is the honest way to converge behavior without converging edges.
  2. Single terminal output. A workflow may have at most one terminal node producing output; two parallel ends fail with ValueError. These handlers emit message-only events, which sidesteps the rule cleanly. If you need one computed final result, add a second routed stage that merges to a single terminal node.
  3. Agents are single_turn in graphs unless placed directly after START, which is why only analyze_severity is an agent and every handler is a function.

6. Running it

from google.adk.runners import InMemoryRunner

runner = InMemoryRunner(agent=root_agent, app_name="triage")

session = await runner.session_service.create_session(
    user_id="oncall", app_name="triage"
)

alert_json = json.dumps({
    "source": "prometheus",
    "service": "checkout-api",
    "metric": "http_error_rate",
    "value": 42.7,
    "threshold": 5.0,
    "message": "Error rate spiked after deploy 9f31c2",
})

async for event in runner.run_async(
    user_id="oncall", session_id=session.id, new_message=alert_json
):
    if event.message and not event.partial:
        print(f"[{event.author}] {event.content.parts[0].text}")

You will see the enrichment progress line, the agent’s assessment, and finally the branch handler’s message — with the route decision reproducible from the logged SeverityAssessment alone.

7. Why this shape is good for on-call

  • The routing table is the runbook, in code. “CRITICAL + ≥100 users → page” is a line you can review, test, and diff — not a behavior inferred from prompt wording. Unit-test router as a pure function of its input, no API key required.
  • Failure modes are visible. Unknown severity values hit DEFAULT_ROUTE and land in the log handler rather than vanishing. Model gibberish that fails schema validation fails the node — loudly — instead of silently routing nowhere.
  • The model’s blast radius is contained. It produces a classification; it cannot skip the enrichment step, bypass the notification helper, or invent a fourth branch. Determinism is structural.
  • Every run is reconstructable. The session records each event — parse, enrichment, assessment, route, notification — so a post-incident review can answer “why didn’t we page?” from history, not from memory.
  • The graph enforces hygiene at build time. Cycles require a routed edge, terminal outputs are limited to one, and the dispatch table must cover the router’s values. Broken topologies fail when the Workflow is constructed, not during an outage.

8. Checklist

  • Parsing and enrichment are deterministic functions; only classification uses a model.
  • The analysis agent has output_schema, so the router receives a validated object.
  • Every route the router can emit has a handler — plus DEFAULT_ROUTE.
  • All branches notify through one shared helper.
  • The router is unit-tested as a pure function of SeverityAssessment.
  • Progress messages (Event(message=...)) never carry graph data; output appears once per node.
  • A test run with a garbage payload exercises the default branch.

Conditional routing turns triage from a prompt suggestion into a reviewed artifact. The model still decides what the alert means; your code decides who gets woken up — and that is the split that makes on-call automation trustworthy.

References