Inferensys

Prompt

Agent-to-Agent Escalation Routing Prompt

A practical prompt playbook for using Agent-to-Agent Escalation Routing Prompt in production AI workflows.
Engineer reviewing agent handoff workflow on laptop, task routing diagrams visible, technical office setup.
PROMPT PLAYBOOK

When to Use This Prompt

Defines the precise operational boundaries for the Agent-to-Agent Escalation Routing Prompt, targeting orchestration engineers who need to automate handoffs between specialized agents.

This prompt is a control-plane component for orchestration engineers and platform builders managing multi-agent topologies. Its job is to produce a structured routing decision when an agent hits a defined boundary and cannot proceed autonomously. The trigger is not a simple error, but a specific operational state: low confidence in an output, a detected capability gap, a policy trigger that requires a different authority level, or a tool failure that the current agent cannot resolve. The output is a machine-readable decision containing a target agent identifier, a context payload for the handoff, and a reason code that logs why the transfer occurred. This is not a prompt for generating user-facing text; it is infrastructure logic expressed in natural language.

The ideal user is an AI platform engineer wiring together an agent mesh. They should use this prompt inside an orchestration layer that reads the routing decision and programmatically executes the handoff. The required context includes the current agent's role and capabilities, the task state, the failure or boundary condition, and a registry of available downstream agents with their specializations. Do not use this prompt for agent-to-human handoffs, which require a different output schema focused on summarization and approval requests. Do not use it for single-agent retry logic, where the correct path is a self-correction or tool-call loop. Do not use it when the current agent can resolve the task with a clarification question or an alternative tool call. Misapplying this prompt in those scenarios will produce unnecessary routing overhead and fragment the task context.

Before implementing, ensure your orchestration layer can parse a strict JSON routing decision and act on it. The prompt's value is in standardizing the handoff contract: every escalation produces the same fields, making agent behavior auditable and the topology reconfigurable without rewriting prompts. If your system lacks a formal agent registry or cannot enforce that the target agent receives the full context payload, the routing decision will be useless. Start by defining the boundary conditions that should trigger this prompt, then map each condition to the reason codes your orchestration layer will log and monitor. Avoid using this prompt as a catch-all error handler; it is a precision tool for planned capability boundaries.

PRACTICAL GUARDRAILS

Use Case Fit

Where the Agent-to-Agent Escalation Routing Prompt works, where it fails, and what you must have in place before deploying it into a production agent mesh.

01

Good Fit: Heterogeneous Agent Fleets

Use when: you have multiple specialized agents with distinct capability boundaries, and a coordinator needs to decide which agent should handle a task or sub-task. Guardrail: define each agent's capability contract in a machine-readable schema so the routing prompt can reason over explicit boundaries rather than guessing.

02

Bad Fit: Single-Agent Monoliths

Avoid when: your system has only one agent or model handling all requests. Adding an escalation routing layer on top of a single-agent system introduces latency and failure points without providing routing value. Guardrail: implement agent specialization and capability boundaries first, then add routing.

03

Required Inputs: Agent Registry and Capability Contracts

Risk: routing prompts produce hallucinated agent names or route to non-existent agents when the available agent list is implicit or stale. Guardrail: provide a live agent registry with capability descriptions, current health status, and input/output schemas as structured context in every routing call.

04

Operational Risk: Context Stripping During Transfer

Risk: the routing agent correctly identifies the target agent but strips essential context from the payload, causing the receiving agent to fail or hallucinate. Guardrail: validate the handoff payload against the target agent's required input schema before transfer, and log context completeness scores for monitoring.

05

Operational Risk: Routing Loops and Ping-Pong

Risk: Agent A escalates to Agent B, which escalates back to Agent A, creating infinite loops that consume compute and delay resolution. Guardrail: include a transfer history trace in the routing context and implement a circuit breaker that terminates routing after a configurable hop limit.

06

Operational Risk: Silent Routing Failures

Risk: the routing prompt returns a valid-looking target agent but the handoff fails silently due to tool unavailability, timeout, or schema mismatch, leaving the task orphaned. Guardrail: implement acknowledgment receipts from target agents and a dead-letter queue for unacknowledged handoffs with alerting thresholds.

PROMPT PLAYBOOK

Copy-Ready Prompt Template

A copy-ready escalation routing prompt that decides which agent should handle a task when the current agent cannot proceed.

This prompt template is designed to be wired into an orchestration layer that manages a fleet of specialized agents. It acts as a decision node, consuming structured context about the current agent's state, the task at hand, the available downstream agents, and the organization's escalation policy. The output is a strict JSON routing decision that your application can parse and execute without ambiguity. Use this when you need a deterministic, auditable handoff between agents rather than an open-ended conversation.

text
You are an escalation router for a multi-agent system. Your job is to decide which agent should handle a task when the current agent cannot proceed.

[CURRENT_AGENT_ROLE]

[TASK_CONTEXT]

[AGENT_CATALOG]

[ESCALATION_POLICY]

[CONSTRAINTS]

Based on the information above, produce a routing decision. If the task should stay with the current agent, set target_agent_id to null and reason_code to "NO_ESCALATION_REQUIRED". If escalation is required, select the best target agent from the catalog and package the essential context for handoff.

Return ONLY valid JSON matching this schema:
{
  "decision": {
    "escalate": boolean,
    "target_agent_id": string | null,
    "reason_code": "CAPABILITY_GAP" | "LOW_CONFIDENCE" | "POLICY_TRIGGER" | "TOOL_FAILURE" | "TIMEOUT" | "NO_ESCALATION_REQUIRED",
    "rationale": string,
    "confidence": number
  },
  "handoff_payload": {
    "task_summary": string,
    "completed_steps": [string],
    "pending_steps": [string],
    "artifacts": [{"id": string, "type": string, "summary": string}],
    "constraints_to_preserve": [string],
    "user_visible_context": string
  }
}

To adapt this template, replace each square-bracket placeholder with structured data from your application state. [CURRENT_AGENT_ROLE] should describe the agent's capabilities, current task, and reason for considering escalation. [TASK_CONTEXT] must include the original user request, any intermediate results, and the specific blocker. [AGENT_CATALOG] is a list of available agents with their IDs, capabilities, and current availability status. [ESCALATION_POLICY] encodes your organization's rules: when to escalate, which agent types handle which scenarios, and any cost or latency constraints. [CONSTRAINTS] can include output length limits, forbidden agent targets, or required approval steps. After adapting, validate that the JSON schema is enforced in your application layer—do not rely on the model alone to produce valid JSON every time.

Before deploying, build a test harness with at least 20 scenarios covering each reason_code. Include edge cases: an agent catalog with no suitable target, a task that partially matches two agents, and a policy that conflicts with capability matching. Measure routing accuracy against human-labeled decisions and track context preservation by having a downstream agent attempt to continue the task using only the handoff_payload. If the downstream agent cannot proceed without re-asking for information, the handoff payload is incomplete. For high-stakes domains, log every routing decision with the full prompt and response for auditability, and consider a human-in-the-loop review step when confidence falls below 0.85 or when reason_code is POLICY_TRIGGER.

IMPLEMENTATION TABLE

Prompt Variables

Required and optional inputs for the Agent-to-Agent Escalation Routing Prompt. Each placeholder must be populated before the prompt is assembled and sent to the model.

PlaceholderPurposeExampleValidation Notes

[CURRENT_AGENT_ROLE]

Identifies the agent making the escalation decision

customer_support_triage_agent

Must match a registered agent ID in the orchestration layer; reject unknown roles

[TASK_CONTEXT]

The original task, user request, or trigger that the current agent is processing

User reports login failure with error code AUTH-503 after password reset

Must be non-empty and under 4000 characters; truncate with truncation marker if needed

[CURRENT_AGENT_CAPABILITIES]

Declared capabilities and boundaries of the current agent

Can handle account recovery, password resets, MFA troubleshooting. Cannot modify auth server configs.

Must be a structured list or capability document; parse for capability gaps before routing

[CONFIDENCE_SCORE]

The current agent's confidence in its ability to resolve the task

0.42

Must be a float between 0.0 and 1.0; reject non-numeric values; scores below 0.5 should trigger escalation consideration

[AVAILABLE_AGENTS]

List of candidate agents with their roles, capabilities, and current load

[{"agent_id":"auth_engineering","capabilities":["auth server config","session management"],"current_load":3}]

Must be valid JSON array; each entry must have agent_id and capabilities fields; validate against agent registry

[ESCALATION_POLICY]

Organizational rules governing when and how to escalate

Escalate to auth_engineering if confidence < 0.6 and task involves server-side auth config. Never escalate billing tasks to auth_engineering.

Must contain explicit routing rules; parse for contradictions; flag policies with no matching available agent

[PREVIOUS_HANDOFFS]

History of prior escalations for this task to prevent loops

[{"from":"frontline_support","to":"customer_support_triage_agent","reason":"auth error beyond scope"}]

Must be valid JSON array or null; if non-empty, check for cycles where target agent appears in from field

[OUTPUT_SCHEMA]

Expected structure for the routing decision output

{"target_agent":"string","reason_code":"string","context_payload":{},"confidence":"float"}

Must be a valid JSON Schema or example structure; validate output against this schema post-generation

PROMPT PLAYBOOK

Implementation Harness Notes

Wire this prompt into an orchestration layer, not a chat interface.

This prompt is a decision node in an agent mesh, not a conversational turn. It expects a structured escalation signal from the current agent and must return a validated routing decision that the orchestration engine can act on without human parsing. The harness is responsible for assembling the prompt, calling the model, validating the output, and executing the handoff. Treat the prompt as a pure function: deterministic inputs, structured output, and a single retry path on validation failure.

The orchestration engine should follow a strict execution sequence. First, receive the current agent's escalation signal and fetch the live agent catalog from the service registry—never hardcode agent names or capabilities in the prompt. Second, assemble the prompt by injecting the catalog, the escalation context, and the output schema into their respective placeholders. Third, call the model with response_format set to json_object and temperature at or below 0.2 to minimize variance in routing decisions. Fourth, validate the output against the expected schema before any routing action: check that target_agent_id exists in the catalog, that handoff_reason_code matches an allowed enum, and that handoff_payload contains all required fields. Fifth, log the full routing decision with a timestamp, session ID, and the raw model response for auditability. Sixth, execute the handoff by posting the handoff_payload to the target agent's input queue. If validation fails, inject the specific validation error into the [CONSTRAINTS] placeholder and retry exactly once. If the target agent is unavailable, fall back to the next_best_agent_id from the validated output or escalate to a human review queue if no fallback exists.

Never route based on an unvalidated model output. A hallucinated agent ID or malformed payload can cause silent handoff failures that are difficult to diagnose in production. Build the harness to fail closed: if validation fails after the retry, if the target agent is unreachable, or if the model returns a refusal, route to a human review queue with the full context preserved. Log every decision path—success, fallback, and failure—so the operations team can monitor escalation rates, fallback frequency, and validation failure patterns over time.

IMPLEMENTATION TABLE

Expected Output Contract

Define the exact shape of the agent-to-agent escalation routing decision. Use this contract to validate the model's output before passing it to the orchestration layer.

Field or ElementType or FormatRequiredValidation Rule

routing_decision

object

Top-level object must parse as valid JSON

routing_decision.target_agent_id

string

Must match a registered agent ID from [AGENT_REGISTRY]; reject unknown IDs

routing_decision.reason_code

enum string

Must be one of: CAPABILITY_GAP, CONFIDENCE_BELOW_THRESHOLD, POLICY_TRIGGER, RISK_EXCEEDS_TOLERANCE, AMBIGUOUS_INTENT, TOOL_FAILURE, TIMEOUT, HUMAN_ESCALATION_REQUIRED

routing_decision.confidence_score

number (0.0-1.0)

Must be a float between 0.0 and 1.0 inclusive; reject values outside range

routing_decision.reason_summary

string

Must be non-empty and under 500 characters; reject empty or over-length strings

context_payload

object

Must contain all fields from [REQUIRED_CONTEXT_SCHEMA]; reject if missing any required field

context_payload.original_task

string

Must be non-empty; reject if null or whitespace-only

context_payload.partial_results

object or null

If present, must match [PARTIAL_RESULTS_SCHEMA]; null allowed when no work was completed

context_payload.failure_context

object

Required when reason_code is TOOL_FAILURE or TIMEOUT; must include error_code and error_message fields

PRACTICAL GUARDRAILS

Common Failure Modes

Agent-to-agent escalation routing prompts fail in predictable ways. These cards cover the most common failure modes, why they happen, and the operational guardrails that prevent them from reaching production.

01

Routing to the Wrong Agent

What to watch: The prompt routes a task to an agent that lacks the required capability, causing silent failure or a secondary escalation loop. This often happens when capability descriptions are vague or overlapping. Guardrail: Include explicit capability contracts in the prompt with a structured mapping of task categories to agent IDs. Validate routing decisions against a golden test set of known capability boundaries before deployment.

02

Context Stripping During Handoff

What to watch: The escalation prompt generates a handoff payload that omits critical context—user intent, partial results, or constraint flags—causing the receiving agent to start from scratch or make incorrect assumptions. Guardrail: Require a structured context payload schema in the prompt output. Run eval checks that compare pre-handoff state against post-handoff task success rates to detect context loss.

03

Infinite Escalation Loops

What to watch: Agent A escalates to Agent B, which escalates back to Agent A, creating a cycle that burns compute and delays resolution. This occurs when escalation criteria are symmetric or when agents share overlapping capability boundaries. Guardrail: Include a loop-detection instruction in the prompt that checks the escalation chain history before routing. Implement a circuit breaker in the orchestration layer that terminates after N hops and forces human review.

04

Over-Escalation on Low-Confidence Edge Cases

What to watch: The prompt escalates too aggressively when confidence is borderline, flooding downstream agents or human reviewers with tasks the original agent could have handled. This defeats the purpose of autonomous routing. Guardrail: Calibrate confidence thresholds with a holdout dataset. Add a cost-awareness instruction that weighs escalation benefit against the downstream agent's load and latency. Track false-positive escalation rates in production.

05

Hallucinated Handoff Reason Codes

What to watch: The prompt generates a plausible but incorrect reason code for escalation—claiming a capability gap that doesn't exist or citing a policy that wasn't triggered—making audit trails unreliable. Guardrail: Constrain reason codes to a closed enum defined in the prompt. Add a grounding check that requires the prompt to cite specific evidence from the task context before selecting a reason code. Validate against known hallucination patterns.

06

Silent Failures from Malformed Payloads

What to watch: The prompt produces a routing decision with a malformed context payload—missing required fields, incorrect types, or truncated content—that the receiving agent cannot parse, causing a silent drop. Guardrail: Define a strict JSON schema for the handoff payload in the prompt. Implement a validation layer in the orchestration harness that rejects malformed outputs and triggers a retry or fallback before the payload reaches the target agent.

IMPLEMENTATION TABLE

Evaluation Rubric

Criteria for evaluating the quality of agent-to-agent escalation routing decisions before deploying the prompt to production. Use these checks in an automated eval harness or manual review gate.

CriterionPass StandardFailure SignalTest Method

Routing Target Validity

Target agent ID matches one of the allowed agents in [AGENT_REGISTRY]

Output references an agent not in the registry or returns null when escalation is required

Schema validation against registry enum; assert target_agent_id in allowed_ids

Reason Code Completeness

Handoff reason code is present and matches one of the predefined codes in [ESCALATION_REASONS]

Missing reason_code field, null value, or code not in allowed enum

Enum membership check; assert reason_code in valid_reason_codes

Context Payload Fidelity

Context payload contains all required fields from [REQUIRED_CONTEXT_SCHEMA] with no fabricated values

Missing required fields, hallucinated user data, or truncated conversation history

Schema validation; diff check against source conversation; assert no fabricated entities

Escalation Threshold Adherence

Escalation is triggered only when confidence_score < [CONFIDENCE_THRESHOLD] or risk_level >= [RISK_THRESHOLD]

Escalation when confidence is above threshold without risk trigger, or no escalation when below threshold

Assert escalation_triggered == (confidence < threshold or risk >= risk_threshold)

Handoff Summary Grounding

Summary text contains only information present in [CONVERSATION_HISTORY] and [AGENT_NOTES]

Summary includes facts not in source context, speculative conclusions, or fabricated user intent

Claim extraction and source grounding check; assert all claims have evidence in source

Latency Budget Compliance

Routing decision is produced within [MAX_LATENCY_MS] milliseconds

Decision exceeds latency budget, causing downstream timeout or SLA breach

Latency measurement in test harness; assert response_time_ms < max_latency_ms

Loop Prevention Signal

Escalation history check prevents routing to an agent that already escalated this task

Task routed back to originating agent or creates circular escalation chain

Inject prior escalation records; assert target_agent_id not in previous_escalation_agents

Fallback Path Validity

When no suitable agent is available, fallback path matches [DEFAULT_FALLBACK_AGENT] or triggers human handoff

Null fallback, routing to decommissioned agent, or silent failure with no handoff

Test with empty or exhausted agent pool; assert fallback_agent_id is valid or human_handoff_triggered == true

ADAPTATION OPTIONS

Adapt This Prompt

How to adapt

Start with the base prompt and a simple JSON schema for the routing decision. Use a single model call without retries. Hardcode the agent registry as a list in the prompt instead of a tool call. Accept any valid JSON output without strict enum validation.

code
You are an escalation router. Given the [CURRENT_AGENT_STATE] and [TASK_CONTEXT], select the best target agent from [AGENT_REGISTRY]. Return JSON with "target_agent", "reason_code", and "context_payload".

Watch for

  • Missing schema checks causing downstream parse failures
  • Overly broad agent descriptions leading to wrong routing
  • No confidence threshold, so low-certainty decisions look identical to high-certainty ones
Prasad Kumkar

About the author

Prasad Kumkar

CEO & MD, Inference Systems

Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.

His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.