Escalation Chain
When several AI agents work for you while you are away from the keyboard, they inevitably hit questions they cannot answer alone. If every worker messages you directly, your inbox fills with things you already wrote down last week — and the one high-stakes choice that genuinely needs your judgment gets buried at the bottom.
Escalation Chain puts a deterministic, ordered series of stops between an asking agent and the human requester. The hub first checks whether you reserved that class of decision for yourself; if not, it tries stored records, then standing policies, then the lead agent, interrupting you only when none of those can settle the question. Reach for it whenever multiple agents raise frequent questions and your attention is the scarcest resource.
Routing step
Why flat asking breaks down at scale
Across engineering, customer operations, procurement, research, and publishing, workers that hit uncertainty face an unfair choice: guess and risk doing the wrong thing, or ask the human requester directly. Asking spares the worker from guessing, so well-behaved agents default to asking.
Multiply that across parallel workers and the requester spends every check-in answering questions that were already settled somewhere else: a fact captured in last week's brief, a standing approval already granted for low-risk actions, or a local choice the lead agent was hired to make. Worse, because every ask arrives in the same flat stream, the requester skims past the queue and misses the one irreversible or customer-facing call — such as issuing refunds or waiving a contract — that truly required her attention.
Escalation Chain replaces ad-hoc asking with four structural rules enforced by the hub:
- Workers ask the hub, never a person directly. A worker states what it needs and keeps working on parts of its job that do not depend on the answer.
- Reserved decisions skip straight to the requester. Before trying lower stops, the hub checks whether a standing policy reserves this decision class for the human.
- Every other question walks four stops in fixed order: stored records, then delegation policies, then the lead agent, and finally the requester.
- Every stop leaves a durable routing step recording who handled it, its deadline, and why it settled or passed the question on — answering "Why are you asking me this?" before the requester has to ask.
Why check reserved decisions before searching stored records? Because a past answer to one specific case must never silently answer a new decision you explicitly kept for yourself. Checking reservations first guarantees that an old refund answer from last month cannot auto-approve a fresh refund today.
Architecture and participants
The Hub owns the route. It stores one
Question record and appends one
Routing step for each stop the question visits. Passing a
question onward never creates a duplicate question; the hub closes the current step as
passed_on, opens the next step in the fixed sequence, and
updates who is currently authorized to settle it.
Question when blocked on an unknown fact,
permission, or choice. Never chooses who answers, and continues independent work while
the chain runs.
Routing step, and
rejects answers from anyone other than the open step's handler.
Execution flow
Toggle between the normal path — where the lead agent settles a question inside its scope without disturbing the requester — and the timeout failure path — where a crashed lead agent triggers automatic escalation and the hub rejects its late reply after restart.
The hub checks reservations first, walks stored records (step 1) and policies (step 2), and hands the question to the lead agent (step 3). The lead agent settles it within its decision scope and deadline; the requester is never interrupted and can audit the route later.
Begins after stops 1 (records) and 2 (policies) have already closed as
passed_on and the hub opens step 3 for the lead agent.
When the lead agent stops responding and due_at passes,
the hub closes step 3 as passed_on and opens step 4
for the requester with the route history. If the restarted lead agent sends a late answer,
the hub rejects it with not_the_open_handler.
Reserved decisions: If a reserving policy matches before step 1, the hub
skips stops 1–3 completely and opens a single step at requester
naming that policy_id.
Concrete examples
Escalation Chain applies anywhere agents escalate questions to a busy human — from customer operations and vendor finance to software engineering.
Example 1 — Customer operations billing dispute
No code or unit tests- Context
- Operations agents are resolving a vendor overbilling incident across 40 accounts while the operations director is in meetings all afternoon. Four questions arise.
- Stops 1–3
-
"Which contract addendum sets the SLA credit rate?" → settled at
Stop 1 (Stored records) from the pinned contract fact.
"May we issue a $35 goodwill credit?" → settled at Stop 2 (Policies) under a standing rule covering credits under $50.
"Should we email accounts before or after the vendor confirms?" → settled at Stop 3 (Lead agent) inside its communications scope. - Reserved bypass
- "Should we waive the disputed $4,200 enterprise invoice?" matches a reserving policy on waivers over $500. It skips stops 1–3 and arrives alone in the director's inbox with the reserving policy attached.
- Outcome
- Three questions are resolved in seconds without breaking the director's focus; the one financial judgment that matters gets an immediate, clear decision.
Example 2 — Duplicate charge bug fix (API service)
Software engineering- Context
- Workers fixing a webhook retry bug that double-charged customers raise four questions during the afternoon while the engineering lead (Requester) is away.
- Stops 1–3
-
"Which queue does the delivery service use?" → settled at
Stop 1 (Stored records) from a fact stated last week.
"May the lead agent merge the approved retry fix?" → settled at Stop 2 (Policies) by a standing rule for checker-approved bug fixes.
"Store failed deliveries in a new table or the existing one?" → passed to Stop 3 (Lead agent), which chooses the existing table within its 10-minute deadline (or escalates automatically to the requester if it times out). - Reserved bypass
- "Should we refund the customers who were charged twice?" is reserved for the requester. The hub sends it straight to stop 4 so no stale answer or broad policy can auto-settle customer refunds.
- Outcome
-
The requester sees one decision at her check-in — the refund — instead of four mixed
chat messages, and every earlier stop's decision is auditable in
routing_steps.
What this pattern is NOT — Single-agent pairing or mandatory release gates
Negative example- Situation
- One person pairs interactively with one coding agent in a single chat session, or a production deployment requires mandatory human approval before shipping.
- Why skip it
- In a one-on-one interactive session, the chain has only a single stop (you), so routing steps add machinery with zero filtering benefit. And for a mandatory release sign-off, use Policy Gate to hold the transition and send the reserved approval straight to the human without walking lower stops.
When to use and when to skip
Use Escalation Chain when
- Multiple agents work asynchronously for one requester who checks in sporadically rather than watching live.
- Agents raise frequent questions, and most can be answered from existing specs, prior answers, standing policies, or lead-agent scope.
- The hub can search stored records and evaluate standing policies deterministically.
- Each request has a lead agent with a clearly bounded decision scope and timeout fallback.
Skip it when
- One person works live with one agent in a single conversation — there are no intermediate stops to walk.
- A hard rule always requires human sign-off on a transition (enforce that with Policy Gate and route the approval directly as reserved).
- The system has no durable specs, facts, or policies for the hub to consult before asking a person.
- Questions are rare enough that direct routing imposes negligible interruption cost.
Data model and hub invariants
Escalation Chain defines one durable table — routing_steps —
and references four records defined by neighboring patterns:
Question (Self-Contained Question),
Party (Orchestrator-Workers),
Policy (Delegation Policy), and
Answer (Tracked Answer).
Reading a question's steps in position order yields the
complete, immutable route the question took.
Question has one or more
Routing step rows (1 to
1+). Each step names one handler
Party, an optional Policy,
and at most one unique Answer when settled.
Table: routing_steps
| Column | Postgres type | Nullability | Notes |
|---|---|---|---|
| id | uuid | NOT NULL, PK | Unique identifier for this routing step. |
| question_id | uuid | NOT NULL, FK | References questions(id); the question being routed. |
| position | integer | NOT NULL | 1-based step index with no gaps; UNIQUE (question_id, position). |
| stop | text | NOT NULL | CHECK (stop IN ('records', 'policies', 'lead_agent', 'requester')). |
| handler_id | uuid | NOT NULL, FK | References parties(id); the hub at stops 1–2, lead or requester at stops 3–4. |
| outcome | text | NULLABLE | CHECK (outcome IN ('settled', 'passed_on', 'withdrawn')); NULL while open. |
| reason | text | NULLABLE | One-sentence explanation of why the step closed; NULL while open. |
| policy_id | uuid | NULLABLE, FK | References policies(id); the settling, scoping, or reserving policy applied. |
| source | jsonb | NULLABLE | Type and ID of the stored record that settled stop 1 (for example, an earlier answer or fact). |
| answer_id | uuid | NULLABLE, FK | References answers(id); set only when outcome = 'settled', unique when non-null. |
| started_at | timestamptz | NOT NULL | When the question arrived at this stop. |
| due_at | timestamptz | NULLABLE | Deadline after which the hub passes the question on; NULL at requester. |
| ended_at | timestamptz | NULLABLE | When the step closed; NULL while open. |
Nine hub invariants
-
01Contiguous 1-based positions per question Database constraint
UNIQUE (question_id, position)andCHECK (position >= 1)ensure steps form a clean sequence, and the hub writes step 1 in the same transaction that creates the question. -
02At most one open routing step per question Database constraint
A partial unique index
UNIQUE (question_id) WHERE ended_at IS NULLguarantees two stops can never simultaneously claim authority over the same open question. -
03Outcome, reason, and end timestamp close together Database constraint
A
CHECKconstraint requires(ended_at IS NULL) = (outcome IS NULL AND reason IS NULL)and non-emptyreasonwhen closed, matching the hub'sreason_requiredguard. -
04Answer links exist only on settled steps and stay unique Database constraint
CHECK ((outcome = 'settled') = (answer_id IS NOT NULL))plus a partial unique indexUNIQUE (answer_id) WHERE answer_id IS NOT NULLenforceanswer_requiredand prevent two steps from pointing at the same answer. -
05Requester stop has no deadline and is never passed on Database constraint
CHECK (NOT (stop = 'requester' AND (due_at IS NOT NULL OR outcome = 'passed_on')))backs the hub'snowhere_to_pass_onguard at the final stop. -
06Fixed monotonic stop order Hub guard
Steps advance strictly along
records → policies → lead_agent → requester. A route never steps backward, and every step before the final one closes aspassed_on. -
07Reserved decisions start directly at the requester Hub guard
startchecks reserving policies before opening stop 1. If a policy witheffect = 'reserve'matches the question'sdecision_class, the route consists of a single step atrequesternaming thatpolicy_id. -
08Only the open step's handler may settle the question Hub guard
settlechecks that the latest step is open and itshandler_idequals the caller; otherwise it fails withnot_the_open_handler. Closed steps are immutable. -
09Policy-backed settlements record a matching policy use Hub guard
Whenever stop 2 (
policies) or stop 3 (lead_agentwithin its decision scope) settles a question under a policy, the hub writes a correspondingPolicy use(defined in Delegation Policy) in the same transaction.
Reference implementation
The same pure routing state machine in Lean, TypeScript, Python, and Elixir. Lookups into stored records and reserving policies are injected as functions so the chain's ordering, reservation bypass, deadline checks, and handler guards stay trivial to verify.
-- Hub guards for Escalation Chain (enforced in code, never in prompts)
-- Pure functional core: the steps list holds the newest step at its head.
inductive Stop where
| records | policies | leadAgent | requester
deriving Repr, BEq, DecidableEq
inductive Outcome where
| settled | passedOn | withdrawn
deriving Repr, BEq, DecidableEq
inductive HubError where
| notTheOpenHandler | answerRequired | reasonRequired | nowhereToPassOn
deriving Repr, BEq
structure Question where
id : String
decisionClass : String
deriving Repr
-- Timestamps are Unix seconds, passed in by the caller.
structure RoutingStep where
id : String
questionId : String
position : Nat
stop : Stop
handlerId : String
outcome : Option Outcome := none
reason : Option String := none
policyId : Option String := none
answerId : Option String := none
startedAt : Nat
dueAt : Option Nat := none
endedAt : Option Nat := none
deriving Repr
-- Lookups the hub supplies; step ids are passed in, as Lean has no UUID generator.
structure Lookups where
reservedBy : Question → Option String
handlerFor : Stop → String
structure SettleInput where
answerId : String
reason : String
policyId : Option String := none
-- ORDER: the stop after this one, if any.
def Stop.next : Stop → Option Stop
| .records => some .policies
| .policies => some .leadAgent
| .leadAgent => some .requester
| .requester => none
-- LIMITS_SEC: requester is the final stop and has no deadline.
def Stop.limitSec : Stop → Option Nat
| .records => some 5
| .policies => some 5
| .leadAgent => some 600
| .requester => none
def blank (s : String) : Bool := s.all Char.isWhitespace
namespace EscalationChain
def openStep (question : Question) (stepId : String) (position : Nat) (stop : Stop)
(lookups : Lookups) (now : Nat) (policyId : Option String) : RoutingStep :=
{ id := stepId, questionId := question.id, position, stop,
handlerId := lookups.handlerFor stop, policyId, startedAt := now,
dueAt := stop.limitSec.map (now + ·) }
def start (question : Question) (stepId : String) (lookups : Lookups) (now : Nat) :
List RoutingStep :=
match lookups.reservedBy question with
| some reservedPolicyId => [openStep question stepId 1 .requester lookups now reservedPolicyId]
| none => [openStep question stepId 1 .records lookups now none]
def settle (steps : List RoutingStep) (actorId : String) (input : SettleInput) (now : Nat) :
Except HubError (List RoutingStep) := do
-- `let pat := e | alt` runs alt when the pattern does not match.
let openStep :: earlier := steps | throw .notTheOpenHandler
unless openStep.endedAt.isNone && openStep.handlerId == actorId do throw .notTheOpenHandler
if blank input.answerId then throw .answerRequired
if blank input.reason then throw .reasonRequired
let closed := { openStep with
answerId := some input.answerId, policyId := input.policyId <|> openStep.policyId,
reason := some input.reason, outcome := some .settled, endedAt := some now }
return closed :: earlier
def passOn (steps : List RoutingStep) (question : Question) (reason : String)
(stepId : String) (lookups : Lookups) (now : Nat) : Except HubError (List RoutingStep) := do
if blank reason then throw .reasonRequired
let current :: earlier := steps | throw .nowhereToPassOn
unless current.endedAt.isNone do throw .nowhereToPassOn
let some nextStop := current.stop.next | throw .nowhereToPassOn
let closed := { current with outcome := some .passedOn, reason := some reason,
endedAt := some now }
let next := openStep question stepId (steps.length + 1) nextStop lookups now none
return next :: closed :: earlier
def isOverdue (steps : List RoutingStep) (now : Nat) : Bool :=
match steps with
| current :: _ => current.endedAt.isNone && current.dueAt.any (now >= ·)
| [] => false
end EscalationChain
-- The requester is the last stop: a chain parked there cannot be passed on.
theorem requester_is_final (s : RoutingStep) (earlier : List RoutingStep) (q : Question)
(reason stepId : String) (l : Lookups) (now : Nat)
(h : s.stop = .requester) (hr : blank reason = false) :
EscalationChain.passOn (s :: earlier) q reason stepId l now = .error .nowhereToPassOn := by
cases hs : s.endedAt <;> simp [EscalationChain.passOn, hr, hs, h, Stop.next] <;> rfl
// Hub guards for Escalation Chain (enforced in code, never in prompts)
type Stop = "records" | "policies" | "lead_agent" | "requester";
type Outcome = "settled" | "passed_on" | "withdrawn";
interface Question {
id: string;
decisionClass: string;
}
interface RoutingStep {
id: string;
questionId: string;
position: number;
stop: Stop;
handlerId: string;
outcome: Outcome | null;
reason: string | null;
policyId: string | null;
answerId: string | null;
startedAt: Date;
dueAt: Date | null;
endedAt: Date | null;
}
interface Lookups {
reservedBy: (q: Question) => string | null;
handlerFor: (stop: Stop) => string;
newId: () => string;
}
const ORDER: Stop[] = ["records", "policies", "lead_agent", "requester"];
const LIMITS_SEC: Partial<Record<Stop, number>> = {
records: 5,
policies: 5,
lead_agent: 600,
};
class EscalationChain {
start(question: Question, lookups: Lookups, now: Date): RoutingStep[] {
const reservedPolicyId = lookups.reservedBy(question);
if (reservedPolicyId) {
return [this.openStep(question, 1, "requester", lookups, now, reservedPolicyId)];
}
return [this.openStep(question, 1, "records", lookups, now, null)];
}
settle(
steps: RoutingStep[],
actorId: string,
input: { answerId: string; reason: string; policyId?: string },
now: Date
): RoutingStep[] {
const open = steps[steps.length - 1];
if (!open || open.endedAt !== null || open.handlerId !== actorId) {
throw new Error("not_the_open_handler");
}
if (!input.answerId.trim()) throw new Error("answer_required");
if (!input.reason.trim()) throw new Error("reason_required");
const closed: RoutingStep = {
...open,
answerId: input.answerId,
policyId: input.policyId ?? open.policyId,
reason: input.reason,
outcome: "settled",
endedAt: now,
};
return [...steps.slice(0, -1), closed];
}
passOn(
steps: RoutingStep[],
question: Question,
reason: string,
lookups: Lookups,
now: Date
): RoutingStep[] {
if (!reason.trim()) throw new Error("reason_required");
const open = steps[steps.length - 1];
if (!open || open.endedAt !== null || open.stop === "requester") {
throw new Error("nowhere_to_pass_on");
}
const nextStop = ORDER[ORDER.indexOf(open.stop) + 1];
const closed: RoutingStep = {
...open,
outcome: "passed_on",
reason,
endedAt: now,
};
const next = this.openStep(question, steps.length + 1, nextStop, lookups, now, null);
return [...steps.slice(0, -1), closed, next];
}
isOverdue(steps: RoutingStep[], now: Date): boolean {
const open = steps[steps.length - 1];
return Boolean(
open && open.endedAt === null && open.dueAt !== null && now.getTime() >= open.dueAt.getTime()
);
}
private openStep(
question: Question,
position: number,
stop: Stop,
lookups: Lookups,
now: Date,
policyId: string | null
): RoutingStep {
const limit = LIMITS_SEC[stop];
return {
id: lookups.newId(),
questionId: question.id,
position,
stop,
handlerId: lookups.handlerFor(stop),
outcome: null,
reason: null,
policyId,
answerId: null,
startedAt: now,
dueAt: limit !== undefined ? new Date(now.getTime() + limit * 1000) : null,
endedAt: null,
};
}
}
# Hub guards for Escalation Chain (enforced in code, never in prompts)
from dataclasses import dataclass, replace
from datetime import datetime, timedelta
from typing import Callable, Literal, Optional
Stop = Literal["records", "policies", "lead_agent", "requester"]
Outcome = Literal["settled", "passed_on", "withdrawn"]
ORDER: list[Stop] = ["records", "policies", "lead_agent", "requester"]
LIMITS_SEC: dict[Stop, int] = {"records": 5, "policies": 5, "lead_agent": 600}
@dataclass(frozen=True)
class Question:
id: str
decision_class: str
@dataclass(frozen=True)
class RoutingStep:
id: str
question_id: str
position: int
stop: Stop
handler_id: str
started_at: datetime
due_at: Optional[datetime] = None
outcome: Optional[Outcome] = None
reason: Optional[str] = None
policy_id: Optional[str] = None
answer_id: Optional[str] = None
ended_at: Optional[datetime] = None
class EscalationError(Exception):
pass
class EscalationChain:
def start(
self,
question: Question,
reserved_by: Callable[[Question], Optional[str]],
handler_for: Callable[[Stop], str],
new_id: Callable[[], str],
now: datetime,
) -> list[RoutingStep]:
policy_id = reserved_by(question)
stop: Stop = "requester" if policy_id else "records"
return [self._open_step(question, 1, stop, handler_for, new_id, now, policy_id)]
def settle(
self,
steps: list[RoutingStep],
actor_id: str,
answer_id: str,
reason: str,
now: datetime,
policy_id: Optional[str] = None,
) -> list[RoutingStep]:
open_step = steps[-1] if steps else None
if open_step is None or open_step.ended_at is not None or open_step.handler_id != actor_id:
raise EscalationError("not_the_open_handler")
if not answer_id.strip():
raise EscalationError("answer_required")
if not reason.strip():
raise EscalationError("reason_required")
closed = replace(
open_step,
answer_id=answer_id,
policy_id=policy_id or open_step.policy_id,
reason=reason,
outcome="settled",
ended_at=now,
)
return [*steps[:-1], closed]
def pass_on(
self,
steps: list[RoutingStep],
question: Question,
reason: str,
handler_for: Callable[[Stop], str],
new_id: Callable[[], str],
now: datetime,
) -> list[RoutingStep]:
if not reason.strip():
raise EscalationError("reason_required")
open_step = steps[-1] if steps else None
if open_step is None or open_step.ended_at is not None or open_step.stop == "requester":
raise EscalationError("nowhere_to_pass_on")
next_stop = ORDER[ORDER.index(open_step.stop) + 1]
closed = replace(open_step, outcome="passed_on", reason=reason, ended_at=now)
next_step = self._open_step(question, len(steps) + 1, next_stop, handler_for, new_id, now, None)
return [*steps[:-1], closed, next_step]
def is_overdue(self, steps: list[RoutingStep], now: datetime) -> bool:
open_step = steps[-1] if steps else None
return bool(
open_step and open_step.ended_at is None and open_step.due_at and now >= open_step.due_at
)
def _open_step(
self,
question: Question,
position: int,
stop: Stop,
handler_for: Callable[[Stop], str],
new_id: Callable[[], str],
now: datetime,
policy_id: Optional[str],
) -> RoutingStep:
limit = LIMITS_SEC.get(stop)
due_at = now + timedelta(seconds=limit) if limit is not None else None
return RoutingStep(
id=new_id(),
question_id=question.id,
position=position,
stop=stop,
handler_id=handler_for(stop),
policy_id=policy_id,
started_at=now,
due_at=due_at,
)
# Hub guards for Escalation Chain (pure functional core; newest step at head)
defmodule RoutingStep do
@enforce_keys [:id, :question_id, :position, :stop, :handler_id, :started_at]
defstruct [:id, :question_id, :position, :stop, :handler_id, :outcome, :reason,
:policy_id, :source, :answer_id, :started_at, :due_at, :ended_at]
end
defmodule Escalation do
@order [:records, :policies, :lead_agent, :requester]
# Limits in seconds; requester is the final stop and has no deadline.
@limits %{records: 5, policies: 5, lead_agent: 600}
def start(question, lookups, now) do
case lookups.reserved_by.(question) do
nil -> [open_step(question, [], :records, lookups, now)]
policy_id -> [%{open_step(question, [], :requester, lookups, now) | policy_id: policy_id}]
end
end
def settle([%RoutingStep{ended_at: nil, handler_id: by} = step | earlier], by, fields, now) do
with {:ok, ans} <- fetch_non_empty(fields, :answer_id, :answer_required),
{:ok, reason} <- fetch_non_empty(fields, :reason, :reason_required) do
updated =
struct!(step, fields ++ [answer_id: ans, reason: reason, outcome: :settled, ended_at: now])
{:ok, [updated | earlier]}
end
end
def settle(_steps, _by, _fields, _now), do: {:error, :not_the_open_handler}
def pass_on(_steps, _question, reason, _lookups, _now)
when not is_binary(reason) or reason == "",
do: {:error, :reason_required}
def pass_on([%RoutingStep{ended_at: nil, stop: stop} = step | earlier], question, reason, lookups, now)
when stop != :requester do
if String.trim(reason) == "" do
{:error, :reason_required}
else
steps = [%{step | outcome: :passed_on, reason: reason, ended_at: now} | earlier]
next = Enum.at(@order, Enum.find_index(@order, &(&1 == stop)) + 1)
{:ok, [open_step(question, steps, next, lookups, now) | steps]}
end
end
def pass_on(_steps, _question, _reason, _lookups, _now), do: {:error, :nowhere_to_pass_on}
def overdue?([%RoutingStep{ended_at: nil, due_at: %DateTime{} = due} | _], now),
do: DateTime.compare(now, due) != :lt
def overdue?(_steps, _now), do: false
defp fetch_non_empty(fields, key, error) do
case Keyword.fetch(fields, key) do
{:ok, val} when is_binary(val) ->
if String.trim(val) != "", do: {:ok, val}, else: {:error, error}
_ ->
{:error, error}
end
end
defp open_step(question, steps, stop, lookups, now) do
%RoutingStep{
id: lookups.new_id.(),
question_id: question.id,
position: length(steps) + 1,
stop: stop,
handler_id: lookups.handler.(stop),
started_at: now,
due_at: if(stop == :requester, do: nil, else: DateTime.add(now, @limits[stop], :second))
}
end
end
Execution trace
Walking Example 2 (duplicate charge bug fix) through these guards shows both normal settlement at the lead agent, rejection of blank reasons and wrong handlers, and a reserved refund bypassing stops 1–3 directly to the requester:
1. steps = chain.start(q_failed_deliveries_table, lookups, new Date("2026-11-17T14:45:00Z"))
-> [step_1: stop="records", handler="hub", due="14:45:05Z"] (not reserved)
2. chain.passOn(steps, q_failed_deliveries_table, "", lookups, new Date("2026-11-17T14:45:01Z"))
-> error: reason_required (every pass-on must explain why the stop could not settle)
3. steps = chain.passOn(steps, q_failed_deliveries_table, "No stored record settles it.", lookups, new Date("2026-11-17T14:45:02Z"))
steps = chain.passOn(steps, q_failed_deliveries_table, "No policy covers it.", lookups, new Date("2026-11-17T14:45:03Z"))
-> open step_3: stop="lead_agent", handler="lead_1", due="14:55:03Z"
4. chain.settle(steps, "worker_1", { answerId: "ans_40", reason: "Guessing existing table." }, new Date("2026-11-17T14:46:00Z"))
-> error: not_the_open_handler (only lead_1 may settle step_3 while it is open)
5. chain.settle(steps, "lead_1", { answerId: "ans_41", reason: "" }, new Date("2026-11-17T14:48:00Z"))
-> error: reason_required (settling must record the basis for the decision)
6. steps = chain.settle(steps, "lead_1", { answerId: "ans_41", policyId: "pol_scope_1",
reason: "Internal schema choice is inside the lead agent's decision scope." }, new Date("2026-11-17T14:49:00Z"))
-> ok (route: [1: records/passed_on, 2: policies/passed_on, 3: lead_agent/settled]; requester uninterrupted)
7. # Reserved decision bypass (customer refunds):
reservedSteps = chain.start(q_double_charge_refund, lookups, new Date("2026-11-17T14:50:00Z"))
-> [step_1: stop="requester", handler="dana", policy_id="pol_reserve_refunds", due=null]
chain.passOn(reservedSteps, q_double_charge_refund, "Cannot decide", lookups, new Date("2026-11-17T14:51:00Z"))
-> error: nowhere_to_pass_on (requester is the final stop)
Tradeoffs and practical guidance
Escalation Chain dramatically cuts human interruptions while preserving authority over high-stakes choices, but it carries real tradeoffs you should design around:
- Slight latency on unreserved human questions: a question that truly needs the requester waits through stops 1–3 before landing in her inbox. Keep stops 1 and 2 fast (seconds) and set a firm, modest deadline on the lead agent.
- Risk of silent wrong answers at early stops: a stale stored fact or an overly broad policy can settle a question before the requester ever sees it. Pair this pattern with Decision Audit so the requester spot-checks decisions settled below her.
-
Matching quality matters: if the hub fails to classify a question's
decision_classaccurately, a reserved decision could slip into stop 1 or stop 3 instead of bypassing them.
Practical implementation notes
- Run stops 1 and 2 inside the hub: relying on workers to "remember to check docs and policies before asking" fails under context pressure; running both stops in hub code guarantees consistent order and complete routing history.
-
Always pass on when in doubt: whether matching by exact decision class or
an LLM classifier, any ambiguity or expired record must close as
passed_onrather than guessing an answer. - Mine routing history for new policies: a decision class that repeatedly passes stops 1–3 and gets the exact same answer from the requester is a prime candidate for a new Delegation Policy.
- Handle crashed lead agents explicitly: either pass the question straight to the requester with the timeout reason (simplest) or open a fresh step for a replacement lead agent while keeping the original step closed.
Known uses and related patterns
- PagerDuty escalation policies: routes incident alerts through ordered escalation levels with per-level timeouts, advancing automatically when a responder fails to acknowledge before the deadline.
- Claude Code permission evaluation & agent teams: evaluates tool calls against ordered deny, ask, and allow rules before prompting, and routes teammate permission prompts through the lead session.
- Tiered technical support (L1/L2/L3): resolves routine lookups and known-issue runbooks at lower tiers while escalating novel or high-severity cases with the full diagnostic trail attached.
- Volgenic: routes worker questions first to their lead agent rather than directly to the human requester, preserving a durable trail when a question is escalated or moved after a lead session stops.
-
Contrast with Chain of Responsibility and Enterprise Integration Patterns:
classic Chain of Responsibility passes a request down handlers until one handles it;
Escalation Chain orders handlers by requester attention cost, combines a
Content-Based Router for reserved bypasses, and keeps a durable
Message History via
routing_steps.
Related patterns
- Delegation Policy — supplies the standing policies checked at stop 2, the lead agent's decision scope at stop 3, and the reserved rules checked upfront.
- Decision Audit — samples questions settled at stops 1–3 so the requester verifies the chain is stopping the right asks.
- Question Inbox — controls when questions reaching stop 4 are batched for check-ins versus interrupting immediately.
- Self-Contained Question & Tracked Answer — define the
Questionrecord entering the chain and theAnswerproduced when a stop settles it. - Policy Gate — blocks a guarded transition until its conditions pass, raising a reserved question straight to stop 4 when human sign-off is required.
- Orchestrator-Workers — defines the
Partyrecord referenced by every routing step'shandler_id.