Practical technical guides

Send Agent Decisions Through a Review Detour You Can Switch On and Off

A switchable review path for agent decisions with entry rules, reviewer capacity, a wait limit and exit criteria, and what a detour costs.

By Sandeep Belgavi · Published 2026-12-06

Flow from Entry rule on the effect, to Review queue with a limit, to Exit rule written first.
Original conceptual diagram by Sandeep Belgavi.

The problem a detour solves

Belgavi's Book Store lets an agent settle help-desk cases: it reads the case, checks the order, and issues a refund, an exchange or an address change. Most weeks nobody needs to look at those decisions one by one. Then something changes. The model behind the agent is upgraded, a new refund policy goes live, or an incident review finds that the agent approved refunds on orders that were never delivered. For a while, the team wants a person to look at every refund before it executes, and then it wants to stop doing that without a redeploy and without forgetting to stop.

Enterprise Integration Patterns names this shape the Detour: a context-based router at the front of a path that, depending on a control condition, either sends messages straight to their destination or routes them through extra steps such as validation, testing or debugging. The extra steps are not part of the normal flow. They are inserted when the control condition says so and bypassed otherwise.

For agent systems the detour is a useful replacement for two common improvisations. The first is editing the prompt to say "be more careful with refunds", which changes nothing anyone can measure. The second is adding a permanent human approval step, which turns a temporary concern into a permanent queue. A detour keeps the review step as a separate, switchable path with explicit entry and exit rules.

What the detour is made of

A detour for agent decisions has five parts, and each one is ordinary code:

  1. A control flag read on every decision, stored where operators can change it without a deploy. Record which flag version each decision saw.
  2. An entry rule that decides which decisions take the detour: every decision, all refunds, or refunds above an amount. It runs on the proposed effect, not on the model's confidence.
  3. A review queue with a known throughput. People review decisions in arrival order, or in an order you define and can explain.
  4. A wait limit and a timeout policy. When a detoured decision has waited longer than the limit, the system either holds it (the customer keeps waiting) or releases it unreviewed (the risk is accepted). Both are legitimate. Choosing neither is not.
  5. An exit rule, either manual or automatic, such as switching the detour off after a number of clean reviews in a row.

The router sits between the agent's proposal and the executor that calls the refund service. The agent itself does not know whether a detour is active. That separation matters: if the agent's prompt mentions the review, its behaviour changes, and you lose the ability to compare decisions before and after.

from dataclasses import dataclass

@dataclass(frozen=True)
class Proposal:
    case_id: str
    kind: str        # "refund", "exchange" or "address"
    amount: int      # 0 when not monetary

@dataclass(frozen=True)
class DetourConfig:
    enabled: bool
    entry: str       # "all", "refunds" or "amount"
    amount_min: int
    version: int

def route(p: Proposal, cfg: DetourConfig) -> str:
    """Return "review" or "execute"; the caller records cfg.version with the decision."""
    if not cfg.enabled:
        return "execute"
    if cfg.entry == "all":
        return "review"
    if p.kind != "refund":
        return "execute"
    if cfg.entry == "refunds" or p.amount >= cfg.amount_min:
        return "review"
    return "execute"

What stays deterministic

Everything in the router is deterministic: the flag, the entry rule, the queue order, the wait limit, the timeout policy and the exit rule. The agent still proposes; it does not decide whether its proposal is reviewed. The reviewer's verdict is recorded as data next to the proposal, with the reviewer's identity, the time and the flag version. The executor only acts on proposals that are routed to "execute" or approved in review, and it checks that the proposal was not changed after approval, for example by comparing a digest of the proposal fields.

Two numbers must be decided before the detour is switched on, because they cannot be tuned honestly afterwards: the wait limit, which is a customer-facing promise, and the reviewer throughput, which is a staffing fact.

A worked example with numbers

The companion lab replays 30 synthetic decisions, one per tick. Nineteen are refunds, six are address changes and five are exchanges. Six decisions are wrong: five large refunds from cases CASE-6004, CASE-6009, CASE-6015, CASE-6022 and CASE-6027, and one exchange, CASE-6013. The reviewer can complete five reviews per ten ticks.

With the detour on, the entry rule set to refunds and a wait limit of six ticks with the release policy, 19 decisions are detoured and the queue peaks at 5. Four wrong refunds are caught. CASE-6027 waits six ticks and is released unreviewed, and the wrong exchange never entered the detour, so two wrong decisions execute. Changing the policy to hold catches five, leaves the exchange as the only escape, and makes three customers wait past the limit, the longest for eight ticks.

Widening the entry rule to every decision looks safer and is worse at this throughput: 30 decisions compete for the same reviewer, 12 are released unreviewed, and only two wrong decisions are caught. With the hold policy instead, all six are caught but the queue reaches 16 and the last decision waits 30 ticks. Doubling throughput to ten reviews per ten ticks catches all six with no waiting. The lesson is not a specific setting. It is that the entry rule, the throughput and the timeout policy are one decision, and the queue tells you which of them you have actually chosen.

An automatic exit rule needs the same care. With an exit after three clean reviews in a row, the detour switches itself off at tick 16, after a run of small refunds, and the wrong refunds at ticks 22 and 27 execute unreviewed. A clean streak measures the recent mix of cases, not the safety of the change that triggered the detour.

Choosing exit criteria

Exit criteria should be stated before entry and tied to the reason for the detour:

  • For a model upgrade: a minimum number of reviewed decisions of each kind the upgrade affects, with the rejection rate under an agreed bound, and a minimum count in the risky band (large refunds here).
  • For a policy change: the detour ends when the policy's own tests pass against reviewed cases and a reviewer has seen at least one case from each rule branch.
  • For an incident: the detour ends when the fix is deployed and a fixed number of post-fix decisions in the affected category have been reviewed.

A time-based exit ("switch off on Friday") is acceptable only when it is paired with a count, because review throughput varies.

Failure modes

  • The flag is cached per worker and some workers keep detouring, or stop detouring, for minutes after a change. Record the flag version on every decision and alert when two versions are active for longer than the propagation budget.
  • The entry rule reads model output that the model can shape, such as a "risk" field it fills in itself. Route on the proposed effect: kind, amount, recipient.
  • The detour becomes permanent. Nobody owns the exit, and the queue becomes the new normal path. Give the detour an owner and an expiry date that pages someone.
  • Approval is not bound to the proposal. The agent revises the case after approval and the executor runs the revised version. Approve a digest, execute only that digest.
  • Reviewers rubber-stamp under load. When the queue grows, review quality drops before throughput does. Track the time per review and sample reviewed decisions for a second look.

Migration steps

  1. Separate proposal from execution if the agent currently calls the refund service directly. The detour needs a place to stand.
  2. Add the router with the flag off and record route decisions and flag versions for a week. Nothing changes for customers.
  3. Build the review queue and measure reviewer throughput on real staffing before choosing a wait limit.
  4. Write down the entry rule, timeout policy and exit criteria for the first use, then switch the flag on for one category.
  5. After the first exit, review the decision log: how many decisions were held, released, caught and approved, and whether the exit criteria were met or merely reached.

When an agent is unnecessary

If the decisions under review follow a short list of rules, such as refund when the order is undelivered after 14 days and the amount is under a limit, a rule engine with tests is simpler than an agent plus a detour. The detour pattern itself does not need an agent: it is equally useful in front of a rules engine during a policy change. Use the agent where judgment over unstructured case text adds value, and keep the detour for the period when that judgment is in question.

Verification

Test the router as a pure function over a table of proposals and configurations. Replay a day of logged proposals through the lab's model, or your own, with your real throughput, and check that the wait limit and the release count are acceptable before switching on. In production, alert on: two flag versions active, queue age above the wait limit, release count above zero when the policy is hold, and a detour that has been on longer than its stated expiry.

Interactive experiment

Review detour: entry rules, reviewer capacity and exit. Adjustable synthetic fixtures, decision traces, reset and JSON export.

Primary references and authorship

Sources read December 6, 2026. Original explanations, measurements and synthetic examples by Sandeep Belgavi. Companion code: Sandeep-BA/agent-decision-lab/examples/python/agent_review_detour. Views are my own and do not represent any employer, past or present.