Skip to content
Blog

Routing Inquiries: Building a Smart Dispatcher for Customer Support Tiers

Build a tier-aware dispatcher in Google ADK that classifies support inquiries and routes them to Tier 1, Tier 2, or VIP agents with state guards.

Published on • November 30, 2026

AI Assistant

Every support organization eventually grows a tiered queue: Tier 1 handles the known scripts, Tier 2 owns the gnarly product bugs, and a small VIP desk deals with enterprise escalations. The trouble starts when you try to model that queue with a single LLM agent — the model sees every tool from every tier at once, misroutes refunds to engineers, and quietly hands a free premium callback to someone on the free plan.

The fix is not a bigger prompt. It is a dispatcher: a thin, front-facing agent whose only job is to classify the inquiry, stamp the customer’s support tier into session state, and hand control to exactly one specialist.

In this tutorial we build that dispatcher with the Google Agent Development Kit (ADK). We cover how Agent(sub_agents=...) produces transfer events, how to encode tier policy in state rather than in prose, how to guard escalation paths with tool_context, and how to run the whole thing through a Runner with an InMemorySessionService.


1. Anatomy of a Tiered Support Queue

Before touching code, map the flow. A tiered queue is a routing problem with two decisions: which specialist owns this, and is this customer allowed to reach them.

   [ inbound inquiry ]
           │
           ▼
  ┌────────────────────┐      state: tier = free | pro | enterprise
  │  support_dispatcher │ ───► classifies intent + reads plan tier
  └────────────────────┘
        │        │        │
        ▼        ▼        ▼
   ┌────────┐ ┌────────┐ ┌────────────┐
   │ tier_1 │ │ tier_2 │ │ vip_desk   │
   │ scripts│ │ deep   │ │ enterprise │
   │ + FAQ  │ │ debug  │ │ escalations│
   └────────┘ └────────┘ └────────────┘

Two properties matter here:

  1. The dispatcher has no domain tools. Its only capability is routing. This keeps its instruction short and its classification sharp.
  2. Tier membership is data, not prose. The customer’s plan lives in session.state; specialists read it. Prompt text alone cannot be audited or tested.

2. How ADK Routes Between Sub-Agents

When you pass agents to the sub_agents parameter of an Agent (an alias for LlmAgent), ADK automatically exposes a delegation tool named after each sub-agent. The parent model decides at inference time which one to call, and the transfer shows up in the event stream as an action carrying the target agent’s name — event.actions.transfer_to_agent.

That single mechanism gives you the dispatcher for free:

from google.adk.agents import Agent

dispatcher = Agent(
    name="support_dispatcher",
    model="gemini-flash-latest",
    instruction="Classify the inquiry and delegate.",
    sub_agents=[tier_1_agent, tier_2_agent, vip_desk_agent],
)

The description field on each sub-agent is the semantic signal the model uses to choose. Vague descriptions produce vague routing, so each tier description must state both a domain and a boundary (“billing and known-issue FAQ for free and pro plans” versus “production incidents for enterprise accounts”).

Control can also be handed back explicitly: a specialist can call transfer_to_agent to return to the dispatcher, which is how a completed Tier 1 script returns the conversation to the front door for the next question.


3. Designing the Dispatcher

Let’s build a three-tier fleet for a fictional SaaS product. The dispatcher’s instruction does three things and nothing else: read the tier, classify the intent, transfer.

from google.adk.agents import Agent
from google.adk.tools import ToolContext
from google.adk.runners import Runner
from google.adk.sessions import InMemorySessionService
from google.genai import types

# --- Tier 1: scripted, high-volume answers -------------------------------

def lookup_faq(article_id: str) -> dict:
    """Returns a canned help-center article. Tier 1 only."""
    articles = {
        "reset-password": {"status": "success",
                           "summary": "Send the user to /reset and ask them to check spam."},
        "invoice-copy": {"status": "success",
                         "summary": "Invoices live under Billing > Documents."},
    }
    return articles.get(article_id, {"status": "error",
                                     "error_message": f"No article {article_id}."})

tier_1_agent = Agent(
    name="tier_1_support",
    model="gemini-flash-latest",
    description="Front-line support for known issues on any plan: password resets, invoice copies, feature how-to questions, and FAQ answers. Never debugs code or handles enterprise escalations.",
    instruction="""You are Tier 1 support.
Answer from `lookup_faq` only. If the issue needs code-level debugging
or the customer is on the enterprise plan, transfer back to `support_dispatcher`.
End every answer with `transfer_to_agent('support_dispatcher')`.""",
    tools=[lookup_faq],
)

# --- Tier 2: deep technical debugging -----------------------------------

def query_service_health(service: str, trace_id: str | None = None) -> dict:
    """Returns synthetic health data for a backend service."""
    return {
        "status": "success",
        "service": service,
        "p95_latency_ms": 412,
        "error_rate": 0.031,
        "suspicious_dep": "auth-edge" if trace_id else None,
    }

tier_2_agent = Agent(
    name="tier_2_engineering",
    model="gemini-flash-latest",
    description="Technical escalation for logged-in users on paid plans: API errors, latency investigations, trace analysis, and suspected outages. Does not handle billing or VIP relationships.",
    instruction="""You are a Tier 2 support engineer.
Investigate with `query_service_health`, explain root cause plainly,
and hand control back to `support_dispatcher` when the ticket is resolved.""",
    tools=[query_service_health],
)

# --- VIP desk: relationship-aware, read-mostly ---------------------------

def open_enterprise_ticket(account: str, severity: str) -> dict:
    """Files a P1/P2 ticket for an enterprise account."""
    return {"status": "success", "ticket": "ENT-4471", "account": account,
            "severity": severity, "sla_hours": 1 if severity == "P1" else 4}

vip_desk_agent = Agent(
    name="vip_desk",
    model="gemini-flash-latest",
    description="Dedicated desk for enterprise-plan accounts only: SLA-driven incidents, contract questions, and named-engineer callbacks.",
    instruction="""You are the VIP desk for enterprise accounts.
Acknowledge the SLA, file tickets with `open_enterprise_ticket`,
and return to `support_dispatcher` once the commitment is recorded.""",
    tools=[open_enterprise_ticket],
)

Note what is absent: Tier 1 cannot file enterprise tickets, and the VIP desk has no FAQ tool. Tool scoping is the first, cheapest tier-enforcement layer — the model cannot call what it was never given.


4. Stamping and Enforcing the Tier with tool_context

Classification is cheap; enforcement is what makes the dispatcher “smart”. We resolve the customer’s plan once, store it in session state, and gate escalation on it.

Function tools in ADK can declare a parameter typed ToolContext; the framework injects it invisibly so the model never sees or sets it:

def resolve_customer_tier(customer_id: str, tool_context: ToolContext) -> dict:
    """Looks up a customer's plan and records it in session state."""
    plans = {"C-100": "free", "C-200": "pro", "C-900": "enterprise"}
    tier = plans.get(customer_id, "free")

    # Writes land in session.state via the event's state_delta.
    tool_context.state["support:tier"] = tier
    tool_context.state["support:routed_count"] = (
        int(tool_context.state.get("support:routed_count", 0)) + 1
    )
    return {"status": "success", "customer_id": customer_id, "tier": tier}

Now the dispatcher itself becomes a router with a policy check:

def escalate(tier: str, tool_context: ToolContext) -> dict:
    """Guards Tier 2 / VIP access against the customer's recorded plan."""
    actual = tool_context.state.get("support:tier", "free")
    if tier == "vip_desk" and actual != "enterprise":
        return {"status": "error",
                "error_message": "VIP desk is enterprise-only; downgrade to tier_2."}
    if tier == "tier_2_engineering" and actual == "free":
        return {"status": "error",
                "error_message": "Free plan is limited to Tier 1 FAQ answers."}
    # A tool may also steer control directly:
    # tool_context.actions.transfer_to_agent = tier
    return {"status": "success", "approved_for": tier}

dispatcher = Agent(
    name="support_dispatcher",
    model="gemini-flash-latest",
    description="Front door for all support inquiries. Classifies intent, verifies the plan tier, and delegates to exactly one specialist.",
    instruction="""You are the support dispatcher for CloudCorp.
1. Call `resolve_customer_tier` once per conversation if `support:tier` is unset.
2. Call `escalate` before delegating to `tier_2_engineering` or `vip_desk`.
3. Route known how-to questions to `tier_1_support`.
4. Answer greetings yourself; never solve technical problems directly.""",
    tools=[resolve_customer_tier, escalate],
    sub_agents=[tier_1_agent, tier_2_agent, vip_desk_agent],
)

Two enforcement mechanisms are now active: tool scoping (what each agent can do) and state gating (what the dispatcher is allowed to hand off). Because support:routed_count lives in state, the same policy can later be extended to a hard cap — “free customers get one Tier 2 interaction per session” — without rewriting any agent instruction.


5. Running the Dispatcher

Wire it up with a Runner and a session service, then drive a multi-turn conversation:

async def main():
    session_service = InMemorySessionService()
    runner = Runner(
        agent=dispatcher,
        app_name="cloudcorp_support",
        session_service=session_service,
    )
    session = await session_service.create_session(
        app_name="cloudcorp_support", user_id="u_1",
        state={"support:customer_id": "C-900"},
    )

    turns = [
        "Customer C-900 says checkout returns 502 on every request since 14:00.",
        "Thanks — while you're here, can we get a named engineer on call?",
    ]
    for turn in turns:
        print(f"\nUSER: {turn}")
        async for event in runner.run_async(
            user_id="u_1", session_id=session.id,
            new_message=types.Content(role="user", parts=[types.Part(text=turn)]),
        ):
            if event.actions and event.actions.transfer_to_agent:
                print(f"  -> transferred to {event.actions.transfer_to_agent}")
            if event.is_final_response() and event.content:
                print("  BOT:", event.content.parts[0].text.strip())

if __name__ == "__main__":
    import asyncio
    asyncio.run(main())

Expected trace. Turn 1: the dispatcher calls resolve_customer_tier("C-900"), records support:tier = "enterprise", approves the escalation, and transfers to tier_2_engineering, which queries service health. Turn 2: the VIP request passes the escalate gate because the tier is enterprise, and control lands on vip_desk. Swap C-900 for C-100 and the same turn returns an error_message from escalate instead of a transfer — the free customer never reaches the VIP desk.


6. Design Trade-offs

LLM routing vs. explicit routing. The pattern above lets the model decide, guided by descriptions and gated by state. ADK also supports fully deterministic selection in the form of an explicit router function that picks one agent per invocation (an experimental RoutedAgent in the TypeScript SDK), which is the right tool when tier policy is contractual rather than advisory. A practical hybrid: keep LLM routing for intent classification, but keep hard policy in Python functions like escalate.

mode on sub-agents. ADK’s collaboration modes let you mark specialists as "task" (clarify with the user, then auto-return) or "single_turn" (no user interaction, return immediately with a result). A VIP incident agent that must stay in multi-turn chat should stay in the default chat mode; a pure “look up the SLA document” helper fits single_turn.

Where state lives. This example uses InMemorySessionService, so tier stamps vanish on restart. For production, swap in a persistent session service — the dispatcher code does not change, only the backend behind session_service.


7. Checklist

  • Dispatcher agent owns no domain tools — only classification and gating functions.
  • Every sub-agent description states both a domain and an explicit boundary.
  • Customer tier is resolved once into session.state under a namespaced key (support:tier), not restated in prose.
  • Escalation paths are validated in Python (escalate), not trusted to prompt adherence.
  • Tool sets are tier-scoped so a misroute cannot perform a privileged action anyway.
  • The event stream is inspected for transfer_to_agent when debugging routing failures.
  • Session storage is swapped from InMemorySessionService before launch.

Sources