H-10Safety, Boundaries & RecoveryEngineeringDesign

Poka-Yoke Boundaries

Validate arguments, syntax and preconditions synchronously inside the tool call, so preventable mistakes never acquire Token Gravity.

Human UXAgent AXError prevention→Poka-yoke boundaries

A sales team in Tokyo runs a scheduling agent. Its job is simple: find a slot, book the call, send the confirmation. On Monday a prospect in São Paulo, Ana, replies to an intro email: "Thursday at 3 p.m. my time works."

The agent looks up Ana's contact record, which says America/Sao_Paulo, and books the call: create_meeting(start="2026-12-03T15:00:00", attendees=["ana@cliente.com.br"]). The tool answers { "meeting_id": "mtg_7781", "status": "scheduled" }. The agent emails Ana: "Confirmed for Thursday, 3 p.m. your time." Done in four seconds.

The timestamp had no time zone. The tool didn't complain. It quietly applied the account's default, Asia/Tokyo, and stored the meeting for 15:00 in Tokyo. In São Paulo that is 3:00 a.m. A nightly sync job noticed that the start fell outside every attendee's working hours and wrote a warning to a log nobody reads.

On Thursday the account executive sits alone in the video call at 3 p.m. Tokyo time. Twelve hours later, Ana opens the link at 3 p.m. her time, as the email promised, and finds an empty room. The first call with a new customer, the one that sets the tone for the deal, is gone.

The agent made a small, common slip. The tool had everything it needed to catch it, including Ana's time zone one lookup away. It caught nothing, said "scheduled," and let the mistake travel for three days.

Why it happens

Book the same call in a calendar app and the slip is hard to make. The time field is a picker, the picker sits next to a time zone label, and many apps show the attendee's local time as you drag the slot. A day like February 30 isn't on offer at all. Jakob Nielsen's usability heuristics call this error prevention: design the screen so the wrong input is hard or impossible to enter. Manufacturing has an older name for it. Shigeo Shingo, working on Toyota's production lines, called it poka-yoke, or "mistake-proofing": a jig that only fits the part one way, so the wrong part never reaches the next station.

The agent gets no picker. It types a string into a field described as start: string. Between "3 p.m. in São Paulo" and a valid call sits a translation the agent has to do in its head: pick a format, convert or annotate the zone, spell it exactly. The Guide calls that distance the gulf of invocationLexicon · 29Gulf of InvocationFriction between an agent's intent and issuing a valid call.: the friction between what the agent means and a call that says it correctly. Every free-text argument widens it.

The schema could have narrowed it. Tool names, parameter names, types and descriptions are the only cues the agent has about how a tool wants to be used, the way a door handle tells you to pull. The Guide calls these cues schema affordancesLexicon · 31Schema AffordancesUsage cues communicated through tool names, parameters and types.. A bare string affords anything. It says nothing about offsets, and the tool's silent default turned that silence into a decision.

Then the tool said "scheduled." From that moment the agent believed the meeting was at 3 p.m. for Ana, and the calendar said 3 a.m. That growing gap between what the agent believes and what is actually true is world-model driftLexicon · 20World-Model DriftDivergence between the agent's internal beliefs and actual environment state.. It starts with one accepted argument and stays invisible until something outside the agent collides with it.

The cheapest moment to catch a mistake is the moment it is typed.

The longer the drift lasts, the harder it is to reverse. Each later turn repeats the wrong fact: the confirmation email, a CRM note, a reminder. A mistake that sits in the context and gets referenced again and again starts to pull the agent's reasoning toward itself. The Guide calls that pull token gravityLexicon · 16Token GravityBulky or salient tokens warping subsequent next-token probabilities toward themselves.. By Thursday, the agent's own history says "3 p.m., confirmed" four times, and that history outweighs a single confused message from Ana.

The figure below follows the bad timestamp from the moment the agent types it. Move the check to different places and watch how much gets built on the mistake before it is caught.

Where is the check?
Agent writes15:00, no offsetcreate_meetingaccepts itStoredas 06:00ZEmail to Ana“Thu 3 p.m.”Nightly synclogs a warningAna’s calendarshows 03:00Two empty callsa human notices8 things built on the mistake2 people reached · undo: reschedule a lost first call

Check by a human, on Thursday. The invite sat at 03:00 in Ana's calendar and two people waited in empty calls, while the agent defends the booking. 8 things are built on the mistake: 4 turns, 4 copies of 3 p.m. in context, 2 people reached. Undo: reschedule a lost first call.

Fig. 10.1Where the check lives decides what the mistake costs. Caught inside the call, the bad timestamp costs one retry. Caught by a nightly job, it has already reached the customer's inbox. Caught by a human on Thursday, two people have waited in empty rooms and the agent's own history argues for the wrong time.

Nothing about the error changes along the path. Only the pile on top of it grows. A check inside the call stops the mistake before anything depends on it. Every stage after that adds turns, copies and people that have to be unwound.

What it costs

Writes that leave the building. Sending an invite to a customer is an action with a wide reach and no real undo. A sent email can't be unsent, and a 3 a.m. calendar entry has already been seen. The Guide calls the scope of an action and how undoable it is its blast radiusLexicon · 40Blast Radius & ReversibilityDeclared risk scope and undoability properties of a tool action.. Strict validation matters most on exactly these tools, where the first wrong call is also the last one you can cleanly take back.

Recovery is far more expensive than prevention. A rejected call costs one turn and maybe 100 tokens. The same mistake found on Thursday costs a cancellation, a new booking, an apology, a manager reading the trace, and a second chance with a customer who may not give one.

Debugging the wrong layer. The trace shows a successful call with a plausible argument. An engineer reading it blames the model ("it should have added the offset") and adds a line to the prompt. The next tool with a date field has the same hole, and the prompt fix doesn't travel with it.

Supervision time. After one missed customer call, someone will ask for human approval on every booking. That queue is a full-time job of checking time zones that a regular expression could have checked for free.

The fix

In plain words: the tool checks everything it can check before it does anything, and it checks it right there in the call.

  1. Arguments. Types, formats, ranges and enums. A timestamp without an offset, a date that doesn't exist, an amount with the wrong number of decimals.
  2. Meaning. Values that are well-formed but ambiguous or implausible. 03/12 could be March or December. A meeting at 3 a.m. for every attendee is almost certainly a mistake.
  3. Preconditions. The state the action depends on. The attendee exists, the slot is free, the referenced object is in the expected state.

When a check fails, the call fails, nothing is written, and the error explains itself. Here is the same booking call, before and after.

Beforecreate_meeting → 14 tok
{
  "meeting_id": "mtg_7781",
  "status": "scheduled" 1
}
  1. 1The tool applied a time zone the agent never chose and reported success. The mistake is now stored, and its only evidence is a field the agent will never look at again.
Tokens14
Invites sent for the wrong time1 invites
Turns built on the mistake4 turns
Aftercreate_meeting → 85 tok
{
  "status": "rejected", 1
  "error": "start_needs_time_zone",
  "received": { "start": "2026-12-03T15:00:00" },
  "expected": "ISO 8601 with an offset, or a time_zone field", 2
  "if_account_default_used": {
    "time_zone": "Asia/Tokyo",
    "ana@cliente.com.br": "Thu 03:00 America/Sao_Paulo" 3
  },
  "side_effects": "none; no invites sent" 4
}
  1. 1The call fails synchronously, inside the same turn. The agent learns about the problem while it still remembers what it meant.
  2. 2The error states the rule and the accepted forms, so the retry needs no guessing about format.
  3. 3Showing what the default would have done costs the tool a lookup of each attendee's time zone. That lookup is what turns an abstract format error into an obvious one: 03:00 for Ana.
  4. 4The response says that nothing happened. The agent knows it is safe to retry and has nothing to clean up.
Tokens85
Invites sent for the wrong time0 invites
Turns built on the mistake0 turns
Illustrative example

Pin 1 is the whole heuristic. The check runs before the write, and its result lands in the same turn as the call. The agent still has Ana's message and her time zone in view, so the retry is one call: start="2026-12-03T15:00:00-03:00".

Pin 2 matters because a rejection without the rule just starts a guessing game. Pin 3 goes further. It translates the abstract problem ("no offset") into its consequence ("03:00 for Ana"), which is the fact that makes the agent's mistake obvious to it. Pin 4 closes the loop: a rejected call must be visibly free of side effects, or the agent can't tell whether a retry will book the meeting twice.

The strongest version of the fix happens before the call is ever made, in the schema. The agent reads the schema every session, so a precise one narrows the gulf of invocation for free:

"start": {
  "type": "string",
  "format": "date-time",
  "pattern": "(Z|[+-]\\d{2}:\\d{2})$",
  "description": "Start time with a UTC offset, e.g. 2026-12-03T15:00:00-03:00"
}

The pattern refuses a bare time, and the description shows one valid value to copy. The server still enforces the same rule on every call, because a schema is advice and the server is the gate.

The same pattern on other tools

Most preventable mistakes come from a few shapes of argument. The lenient version accepts them and fails later. The poka-yoke version rejects them in the call.

ArgumentAccepted silentlyChecked at the boundary
Timestamp2026-12-03T15:00:00, account zone appliedOffset or named zone (America/Sao_Paulo) required; attendee local times shown
Calendar date2026-02-30 rolled to March 2Rejected: February 2026 has 28 days
Moneyamount: 1250 meant as dollars, read as centsamount_minor and currency required, or an explicit unit
IdentifierA subscription ID passed where a customer ID belongsPrefix and type checked: expected cus_…, got sub_…
File path../../etc/hosts from a workspace toolResolved and rejected if outside the workspace root
Preconditiondeploy(env="prod") on a build whose tests never ranRejected with the missing step: tests: not run for build 812

A rule of thumb for which checks to write first: list the defaults your tool applies when an argument is missing or vague. Each one is a decision the tool makes on the agent's behalf. Either make it explicit in the response, or refuse to make it.

In MCP terms

In an MCP server, the boundary has two sides: the inputSchema the agent reads before it calls create_meeting, and the result it gets back when the call is refused. The spec is clear that the refusal belongs in the result.

  • Input schema (inputSchema). Use the format and pattern from the fix, and set additionalProperties: false so the server rejects a misspelled timezone instead of ignoring it.
  • Tool execution errors (isError: true). The spec lists "Input validation errors (e.g., date in wrong format, value out of range)" among the errors to return as a result. Sent as a protocol error instead, "the LLM would not be able to see that an error occurred and self-correct."
  • Protocol errors (JSON-RPC error). Keep these for requests that aren't valid tool calls at all, such as an unknown tool name. The spec describes them as issues "models are less likely to be able to fix." A missing offset is the model's to fix, so never send it this way.
  • Not in the protocol. Nothing promises that the client checks arguments against inputSchema before sending, and there are no fields for the rule, the received value or the side effects. Servers must "Validate all tool inputs" anyway, and the details go in the result text.

Here is the rejection from the fix, as an MCP result:

{
  "isError": true,
  "content": [{
    "type": "text",
    "text": "Rejected: start 2026-12-03T15:00:00 has no UTC offset. With the account default (Asia/Tokyo), Ana gets Thu 03:00 in São Paulo. Send 2026-12-03T15:00:00-03:00 or a time_zone field. Nothing was booked and no invites were sent."
  }]
}

The agent reads it in the same turn as its call, with Ana's time zone still in view.

Spot it in your traces

Here is the booking session as it would appear in the trace log, including the Thursday follow-up. Watch turn 2, where the mistake gets in, and turn 5, where it defends itself.

TraceA scheduling agent booking a first call across time zones
  1. T1
    get_contact(email="ana@cliente.com.br")→ { "name": "Ana Lima", "time_zone": "America/Sao_Paulo" }Ana is in São Paulo. She wants Thursday at 3 p.m. her time.The agent has the right fact. The tool it calls next could have used it too.
  2. T2
    create_meeting(start="2026-12-03T15:00:00", attendees=["ana@…"])→ { "meeting_id": "mtg_7781", "status": "scheduled" }Booked for Thursday at 3 p.m.No offset. The tool applied Asia/Tokyo without saying so. This is the only turn where a check was cheap.
  3. T3
    send_email(to="ana@…", template="meeting_confirmed")→ { "status": "sent" }Confirmation sent: Thursday, 3 p.m. her time.The mistake leaves the system. It can now only be apologized for.
  4. T4
    read_inbox(since="2026-12-03")→ Ana: "I joined at 3pm, nobody was there?"Ana says nobody joined.The failure surfaces three days and two people later.
  5. T5
    get_meeting(id="mtg_7781")→ { "start": "2026-12-03T06:00:00Z" }The meeting was at 15:00 as confirmed. Ana may have the wrong time zone.Token gravity: four turns of "3 p.m., confirmed" outweigh the stored UTC time. The agent defends the booking instead of converting 06:00Z to 03:00 in São Paulo.

Every call in that trace succeeded. To find the same pattern in your own logs, look for these signals:

  • Timestamps without offsets in tool arguments. Search calls for values that end in a bare time, such as the regex T\d{2}:\d{2}(:\d{2})?" with no Z or +hh:mm after it. Each hit is a call where the tool chose the time zone.
  • A write followed later by its own repair. A create that is cancelled, updated or deleted within a few turns or days, on the same object. Ask what the tool accepted the first time.
  • Human corrections that name a unit. Phrases like "3 a.m.", "wrong time zone", "that's in cents", "the other account". Each points to an argument the boundary should have pinned down.
  • Defaults applied without being asked. Instrument your tools to count calls where they filled in a time zone, currency, unit or environment the caller didn't pass. A high count is a list of future incidents.
  • Async warnings about objects the agent called done. Join background job logs to the objects agents created. A warning on mtg_7781 after the agent reported success is a check that ran in the wrong place.

Review checklist

Run these against every tool that takes structured arguments, starting with the ones that write, send or spend. Each check is a single call or a short read of the code.

Review checklist · 7 items
  1. Reject timestamps that have no UTC offset or time zone, instead of applying a default.How to check Call the tool with 2026-12-03T15:00:00. It should return an error that names the missing offset and writes nothing.
  2. Validate every argument's format, range and enum before any side effect.How to check Pass 2026-02-30, a negative amount and a misspelled enum value in turn. Each call should fail in the same turn, and none should create a record.
  3. Check the preconditions the action depends on inside the call: the referenced objects exist and are in the expected state.How to check Call the tool with an ID from another object type or a deleted object. The error should name the expected type or state.
  4. Flag values that are well-formed but implausible, such as a meeting outside every attendee's working hours, and require an explicit override.How to check Book a 03:00 local meeting. The call should fail unless an argument like allow_outside_hours: true is passed.
  5. Make every rejection state the rule, the received value and the accepted forms.How to check Trigger any validation error. The response should contain the field name, the value received and one valid example.
  6. Say explicitly that a rejected call had no side effects.How to check Trigger a validation error, then inspect the target system. Nothing should have changed, and the response should say so.
  7. Encode the rule in the schema as well: a format, a pattern or a separate required field, plus a description with one valid example.How to check Read the tool definition the agent sees. A new engineer should be able to write a valid value from it without reading the code.

When laws collide

Strict boundaries add rejections, and every rejection costs a turn. That pulls against some laws and reinforces others.

  • Pulls against · H-08Compositional Accelerators
    Where they clash
    Compositional Accelerators asks for batch calls, such as booking 40 meetings in one request. Strict validation can make one bad row reject the whole batch, and an agent that fixes one row per turn pays for 40 rejections.
    How to have both
    Validate every row before running any of them, and return all failures at once, each with its row index and reason. Default to all-or-nothing, and offer an explicit partial: true for callers who want the valid rows to go ahead.
  • Pulls against · H-05Align with Interface Priors
    Where they clash
    Models write what they have seen most often. Naive ISO timestamps and US-style dates are common in training data, so a strict tool rejects some of the agent's most natural first attempts and adds turns.
    How to have both
    Accept every format that is unambiguous, including Z, numeric offsets and a separate time_zone field. Reject only what is ambiguous, and put one valid example in the parameter description, so the first attempt is usually right.
  • Works with · H-11Errors as Steering Prompts
    How they combine
    This heuristic decides when the tool says no: early, inside the call. Errors as Steering Prompts decides what the no says: the rule, the observed state and the next valid call.
    What you get
    Together they turn a mistake into a one-turn detour. The agent is stopped before anything depends on the error, and the rejection hands it the corrected call.

Model size shifts where the help lands. A larger model may add the offset unprompted most of the time, and a smaller one may not. The boundary catches both, which is why the fix belongs in the tool and not in the prompt.

Terms from this page

29Gulf of Invocation
Friction between an agent's intent and issuing a valid call.
31Schema Affordances
Usage cues communicated through tool names, parameters and types.
20World-Model Drift
Divergence between the agent's internal beliefs and actual environment state.
16Token Gravity
Bulky or salient tokens warping subsequent next-token probabilities toward themselves.
40Blast Radius & Reversibility
Declared risk scope and undoability properties of a tool action.
esc

Try “tokens”, “errors”, “stale”, “handoff” or “blast radius”.