Skip to content
AgenticAIWiki
  1. Learn
  2. Part 8
  3. 45. Guardrails and escalation
  4. 45.3

Lesson 45.3 · 3 of 4 · 5 min read · Reviewed 24 Nov 2026

When to escalate instead of resolve

By the end, you can

  • Decide when an agent should hand off to a person instead of continuing.
  • Write an escalation that gives the person everything they need.

A well-built agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. knows its limits. EscalationEscalation: Handing a case from an agent to a person, with the context needed to continue. is handing the case to a person in a way that moves it forward.

Good reasons to escalate

  • No authority. The action is above the agent’s limit or needs a role it doesn’t have.
  • Missing information. The facts it needs aren’t in any tool it can reach.
  • Policy conflict or gap. The rules don’t cover the case, or two rules disagree.
  • The customer asks for a person. Respect it.
  • Repeated failure. The same step has failed several times.

A weak reason

Frustration alone. If a customer is annoyed about a late parcel and the agent can fix it, fixing it is the best service. Sentiment can raise priority, but it shouldn’t replace solving the problem.

What a handoff should contain

  1. A one-line summary of the request.
  2. What the agent checked and tried.
  3. The facts found: order, amounts, dates.
  4. The decision needed, and the agent’s recommendation if it has one.

Pass this as structured fields where you can, so the person or the next system doesn’t have to reread the whole conversation.

Key points

  • Escalate when the agent lacks authority, lacks information, sees conflicting policy, or the customer asks for a person.
  • Don't escalate on sentiment alone; an annoyed customer with a simple problem still wants it solved.
  • A good handoff includes a summary, what was tried, the facts found and the decision needed.
Hands-on labRuns in the Playground

Decide when to escalate, then hand off

Escalate for the right reasons and pass a handoff that moves the case forward.

You will have: An escalation rule and a handoff builder, run over five support cases.

Steps

  1. Run the starter: it escalates only the angry customer, which is the wrong call.
  2. Rewrite should_escalate() with the five good reasons from the lesson.
  3. Make sure mood alone never triggers an escalation.
  4. Build the handoff with summary, tried, facts and decision_needed.
  5. Run it and check each case against the lesson's list.

Done when

  • T2, the angry parcel case, is resolved, not escalated.
  • T1 escalates for no authority, T3 for a person, T4 for repeated failure, T5 for a policy gap.
  • Every handoff has the four fields.

Open in the Playground No API key needed.

Starter code (Python)
# Decide when to escalate, then write a handoff a person can act on without rereading.
CASES = [
    {"id": "T1", "ask": "Refund a 900 credit order", "amount": 900, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": True, "failures": 0, "mood": "polite",
     "tried": ["looked up order 4410", "checked refund policy"], "facts": {"order": 4410, "amount": 900}},
    {"id": "T2", "ask": "Where is my parcel? It is 3 days late!!", "amount": 0, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": True, "failures": 0, "mood": "angry",
     "tried": ["checked tracking"], "facts": {"tracking": "out for delivery today"}},
    {"id": "T3", "ask": "I want to talk to a person", "amount": 0, "limit": 500, "wants_person": True,
     "has_info": True, "policy_covers": True, "failures": 0, "mood": "calm",
     "tried": [], "facts": {}},
    {"id": "T4", "ask": "Change my billing address", "amount": 0, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": True, "failures": 3, "mood": "calm",
     "tried": ["update_address x3, same validation error"], "facts": {"error": "postcode format rejected"}},
    {"id": "T5", "ask": "Can I return a gift bought abroad?", "amount": 0, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": False, "failures": 0, "mood": "calm",
     "tried": ["searched returns policy"], "facts": {"policy": "no rule for overseas purchases"}},
]


def should_escalate(case):
    """Return a reason string to escalate, or None to resolve it yourself."""
    # TODO: escalate for: asked for a person, no authority, missing information, policy gap, repeated failure (3+)
    # TODO: do NOT escalate on mood alone
    if case["mood"] == "angry":
        return "customer is angry"
    return None


def handoff(case, reason):
    # TODO: return a dict with summary, tried, facts and decision_needed
    return {"summary": case["ask"]}


for case in CASES:
    reason = should_escalate(case)
    if reason is None:
        print(f"{case['id']}: resolve")
    else:
        h = handoff(case, reason)
        print(f"{case['id']}: escalate ({reason}) -> {sorted(h)}")
Show a solution
# Decide when to escalate, then write a handoff a person can act on without rereading.
CASES = [
    {"id": "T1", "ask": "Refund a 900 credit order", "amount": 900, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": True, "failures": 0, "mood": "polite",
     "tried": ["looked up order 4410", "checked refund policy"], "facts": {"order": 4410, "amount": 900}},
    {"id": "T2", "ask": "Where is my parcel? It is 3 days late!!", "amount": 0, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": True, "failures": 0, "mood": "angry",
     "tried": ["checked tracking"], "facts": {"tracking": "out for delivery today"}},
    {"id": "T3", "ask": "I want to talk to a person", "amount": 0, "limit": 500, "wants_person": True,
     "has_info": True, "policy_covers": True, "failures": 0, "mood": "calm",
     "tried": [], "facts": {}},
    {"id": "T4", "ask": "Change my billing address", "amount": 0, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": True, "failures": 3, "mood": "calm",
     "tried": ["update_address x3, same validation error"], "facts": {"error": "postcode format rejected"}},
    {"id": "T5", "ask": "Can I return a gift bought abroad?", "amount": 0, "limit": 500, "wants_person": False,
     "has_info": True, "policy_covers": False, "failures": 0, "mood": "calm",
     "tried": ["searched returns policy"], "facts": {"policy": "no rule for overseas purchases"}},
]


def should_escalate(case):
    """Return a reason string to escalate, or None to resolve it yourself."""
    if case["wants_person"]:
        return "asked for a person"
    if case["amount"] > case["limit"]:
        return "no authority"
    if not case["has_info"]:
        return "missing information"
    if not case["policy_covers"]:
        return "policy gap"
    if case["failures"] >= 3:
        return "repeated failure"
    return None   # mood can raise priority, but it is not a reason on its own


def handoff(case, reason):
    return {
        "summary": case["ask"],
        "tried": case["tried"],
        "facts": case["facts"],
        "decision_needed": f"{reason}: a person must decide the next step",
    }


for case in CASES:
    reason = should_escalate(case)
    if reason is None:
        print(f"{case['id']}: resolve")
    else:
        h = handoff(case, reason)
        print(f"{case['id']}: escalate ({reason}) -> {sorted(h)}")
Quick checkA customer politely asks for a refund that is above the agent's limit. What should the agent do?
How sure are you?
Pick an answer and how sure you are