Skip to content

A Prompt Is Not an Approval Gate: Enforcing Agent Behavior at Runtime

#llm-agents #human-in-the-loop #tool-use #process-grounding #agent-memory

A Prompt Is Not an Approval Gate: Enforcing Agent Behavior at Runtime ​

The rule is usually one sentence in a system prompt: confirm with the customer before you change anything. The model follows it as reliably as it feels like following it. That is a suggestion with good manners, not a control.

The Concordat authors put a number on the gap. They took tau-bench's 50 airline tasks and added simulated customers who push back, complain, and ask for speed. The unmodified agent changed a booking without the required explicit "yes" in 13 of 50 tasks on gpt-4.1, and in 29 of 128 runs on Claude Haiku 5.5. Call it one in four conversations where someone leaned on the agent and it quietly mutated a booking.

The part that should bother you is the scoreboard. tau-bench's own reward barely noticed. The task completed, the customer got what they asked for, the row changed. If your eval only looks at final state, it will hand you a passing grade while the agent skips exactly the step your compliance team cares about.

Four sources here attack one seam from different angles: a runtime protocol library, a working approval gate built in Dart, a process-aware retrieval layer for enterprise APIs, and a memory architecture that separates what happened from how someone felt about it. All four pull a constraint out of generated text and into a structure the model cannot argue its way past.

Enforcement at the edge of the tool call ​

Concordat models an agent as an object whose interface is a finite-state protocol, borrowing from typestate and session types. The mechanics are simple enough to describe in four lines:

  • On every turn, the model is offered only the tools legal in the current protocol state.
  • A call outside that set is rejected before it runs, so there is no partial write and no side effect to clean up.
  • Decisions reserved for humans can only be requested, never taken.
  • Token and tool-call budgets are charged per turn and split linearly across handoffs.

The action-space reduction is the practical win. In a support flow with five states, the model sees maybe four legal tools on any given turn instead of your entire catalogue of forty. Fewer legal moves means fewer illegal ones, and the ones that remain are the ones somebody actually reviewed.

Protocols are checked at definition time, and a subclass that could bypass its parent's protocol is rejected outright. That is Liskov substitution applied to behavior rather than types. If a teammate writes PriorityCustomerAgent with a shortcut that skips confirmation, the class does not load.

MechanismWhere the rule livesWhat it catchesWhat it misses
Prompt instructionNatural language in the system promptNothing at runtimeAnything the model can be talked out of
Post-hoc log auditPipeline after the factPast violationsThe damage already done
Runtime protocol (Concordat)Legal tool set per stateCalls outside the current stateLegal calls made for bad reasons
Approval interruptExecutor wrapper around named toolsConsequential actionsCheap actions you left ungated

Concordat does not improve task success. The authors report no meaningful difference against the standard agent on the same tasks. The entire gain is in violations that never happen, which is a strange thing to celebrate and exactly the thing enterprises need before they let an agent touch production data.

Quick Take: Protocols, approval interrupts, and process-grounded retrieval all share one property. They live outside the model's generated text, so the model cannot talk its way past them.

What an approval gate looks like when you build one ​

There is a working version of this in Dart, and the shape is worth copying even if you never touch the language. A dispatch assistant for a field service company has three tools. lookup_work_order and schedule_visit run on their own. order_part costs money, so it waits for a person.

Four pieces: the back office exposed as an MCP server on loopback, a Genkit flow that pulls its tools from that server and never imports the back office directly, an approval middleware in front of the money tool, and one HTTP endpoint. The MCP boundary looks redundant when everything lives in one process. It is not. When the work orders move to a real ERP, only the MCP server changes and the agent, its prompt, and its tests stay put.

The gate itself is one argument: pass the middleware the list of tools allowed to run without asking, and everything else interrupts generation. The response comes back with finishReason == interrupted. The flow stores the conversation plus the held tool request under an approvalId and answers the client immediately with something like "Ordering a heating element for WO-1044 needs your approval."

Approve restarts the held call and the tool runs for real. Decline never touches the executor; the model receives "Declined by the dispatcher. Nothing was ordered." as a tool output and explains that to the user in its own words. The model still gets to talk. It just doesn't get to spend.

Each approvalId answers exactly once and is removed from the pending map on first use, which kills the double-tap two-orders bug before it exists. Pending approvals live in memory on a single Cloud Run instance, which is fine for a demo and wrong for anything else. I'll come back to that.

The deployment is a 20.7 MB native binary on a scratch base image (6 MB compressed), holding the agent, the MCP server, and the HTTP router in one process. A 21 MB image with no runtime to patch means a container that starts fast and has almost no attack surface left in it. The test suite runs 14 tests against a fake model over real loopback HTTP, with no API key and no Gemini call. The expensive, non-deterministic part is the only thing faked, which is why the approval logic is safe to refactor.

The bug that only shows up on the resume path ​

Wiring the gate took three lines. Making the restart work took an afternoon.

Lookups ran fine. Bookings ran fine. The approval prompt appeared. I approved, and the restart threw "Tool order_part not found". The cause is a name mismatch between two code paths that should have been identical. MCP tools register under a namespaced name, work-orders/order_part. The model sees the short name and echoes it back. The normal tool loop resolves that through a short-name map, so the call lands. The resume path calls the executor without that map, falls back to a registry lookup for the bare name, misses, and throws.

Which means every MCP tool works until you put an approval in front of it. That is a nasty failure mode: the feature that is supposed to make the agent safer is the one that breaks first.

I reproduced it with a fake model and two tests. One tool with a plain name, one registered as work-orders/order_part. Plain passed, namespaced failed. A local patch through dependency_overrides passed the map on the restart path and both went green. It is filed as genkit-ai/genkit-dart#657 with the fix in #658, and until that ships the workaround is a local tool under the bare name that forwards to the MCP one.

The lesson generalizes past Dart. The interrupt branch is a separate code path from the happy path, and almost nobody had exercised it when this was written. If you build a gate today, write a test that requests the gated tool and asserts both approve and decline before you trust the gate with anything that costs money.

Holding an approval is not approving it ​

The comments on that write-up went straight at the weak spot. Held approvals sit in an in-memory map on one instance. Restart the container and the dispatcher's pending approval is gone. Run two instances and the approve click can land on a process that has never heard of that approvalId.

Staleness is the worse problem. A held part order carries a part number, a quantity, and a price. Between the hold and the click, the price changes, the part goes out of stock, or the work order gets reassigned to another technician. Replaying the stored call at resume time executes a decision the operator made about a world that no longer exists. The gate stays closed and the audit trail says a human approved it, which is technically true and practically useless.

What I'd change in the next version: bind each approval to an action, a target, the exact arguments, and an expiry. Persist the held call in a database. On resume, re-read current state, re-check the arguments against a spend ceiling, and expire anything older than a shift change. An approval is a record of intent, not a blank check that the executor can reuse.

Key numbers

  • 13 of 50 airline tasks where the standard agent skipped required confirmation under customer pressure, versus 0 for the Concordat agent.
  • 3 of 101 write runs produced an invalid API call with full typed process context, against 46% with valid code lists alone.
  • 38.7% multi-step task completion from process-aware retrieval, against 10.3% for chunk-based retrieval.
  • 20.7 MB on disk for a Dart agent server, MCP server, and HTTP router compiled into one native binary.

One more detail from that thread I wish I'd done from the start: return the hold as a normal tool result ("held, needs approval, id 1") instead of an error. I tried the error version first and watched the model retry the same call three turns in a row, burning its turn budget against a wall. A normal result lets the agent plan around the hold and tell the user what it is waiting for.

Grounding on the process, not just the endpoint ​

Enterprise agents fail at four things, not one. They pick the wrong endpoint. They call the right endpoints in the wrong order. They use invalid payload keys. They invent coded values that don't exist in the enum.

Retrieval-augmented service discovery usually handles the first and ignores the rest, because it scores endpoints independently and returns a ranked list. The process-aware approach in this cluster builds a typed property graph from OData metadata plus BPMN reference processes. A hybrid retriever gets candidates from dense embeddings, then follows process edges to pull in the endpoints that legally come next. On 42 enterprise services with process-chain ground truth, Recall@3 improves by 5.7 points on queries with low lexical overlap between the query and downstream entities (n=74), and matches dense retrieval everywhere else.

The control experiment is the interesting part. On OpenAPI services with no process layer, the method provides no improvement at all. The gain comes from process structure, not from having a more elaborate graph.

Backed by that retrieval, an LLM agent finishes 38.7% of 81 multi-step queries end to end, against 10.3% for a chunk-based baseline. That is roughly 4x, and it is still a system that fails three of five tasks. Read it honestly: process grounding moves an agent from unusable to supervised, which is the gap most enterprise pilots are actually stuck in.

The elicitation probe is where the schema half shows up. Handing the model the valid code lists eliminated invented codes entirely, but 46% of write runs still used invalid payload keys. Full typed context, meaning keys plus process order plus enums, cut invalid calls to 3 of 101 runs. Giving a model an enum is the easy half. The key names are the half people skip.

Memory: three views instead of one similarity score ​

ETAMem starts from two diagnoses. Information entanglement, where unrelated facts get packed into one coarse memory unit, and organizational mismatch, where everything gets filed by semantic similarity even when the useful association is temporal or emotional.

The fix parses conversations into atomic memory units, tags affective content, and organizes the result into three hierarchical views. Thresholds adjust as memory grows. Retrieval allocates a query-specific budget across the views using entropy, then searches hierarchically inside each one.

ViewHoldsAnswers questions like
EventAtomic actions, entities, outcomes"Which work order did we order the heating element for?"
AffectSentiment, preferences, complaints"Does this customer hate being called?"
TimeOrdering, recency, duration"Did they approve before or after the price changed?"

The numbers are 12.46% relative accuracy over the state of the art on LoCoMo and 7.96% on LongMemEval-S, with token usage roughly in line with existing systems. Relative, not absolute: a baseline at 60% becomes roughly 67%. Memory benchmarks are crowded at the top and the remaining points are expensive, so 12% is a real gap, not a rounding artifact.

Why this belongs in a cluster about control: an agent that has to decide whether a customer already approved a change needs all three views at once. Semantic-only retrieval will surface a conversation from eight months ago because it sounds like today's, and your approval gate will fire on a stale yes. Memory architecture and approval semantics are the same problem wearing different hats.

Common Pitfalls ​

Gating in the prompt. "Always confirm before changing anything" is a sentence the model can be argued out of by a customer in a hurry. Move the gate into middleware or a protocol state and leave the prompt to explain the behavior, not enforce it.

Approving a conversation instead of an action. A "yes" from three turns ago is not authorization for a larger order. Bind approvals to the specific tool, target, arguments, and expiry, and re-validate on resume.

Never testing the resume path. The interrupt branch is separate code from the normal tool loop, and framework support for MCP plus interrupts is young. Write a fake model that requests the gated tool and assert both approve and decline before you trust it.

Keeping pending approvals in process memory. A dictionary on one instance dies on restart and cannot survive horizontal scaling. Persist the held call, expire it, and re-check arguments against current state when the operator clicks.

Retrieving endpoints without process edges. A ranked list of individually valid endpoints teaches the agent legal calls but not legal order. If your agent has to chain three enterprise APIs, add the process layer before you blame the model.

One Thing to Remember ​

Protocols, gates, and process graphs are the cheap part. The hard part is deciding which actions deserve a gate and what exactly that gate approves. Every failure in this cluster happens at the same seam: comparing what the model intends to do right now against state you stored earlier, with a handler that quietly assumes the two still agree. The gate is not the safety. The re-validation at resume time is.

The Bottom Line ​

If your agent can move money, book a resource, or delete a record, stop writing sentences about it and put an interrupt in the executor. One-shot approval ids, arguments bound to the specific call, and an expiry window. The Dart version ships in a 21 MB container and the Concordat results drop unapproved mutations from 26% to zero without hurting task success, so there is no cost argument left against doing this.

If your agent calls enterprise APIs in sequence, fix retrieval before you upgrade the model. 38.7% versus 10.3% on multi-step tasks is a larger jump than most model swaps deliver, and the gain disappears the moment the process layer disappears, which tells you exactly where it came from. Add OData keys and BPMN edges, not more chunks.

If you're running long conversations with returning users, watch memory. ETAMem's 12.46% relative gain on LoCoMo is a signal that flat semantic storage is hitting a ceiling, and the fix (separate views for event, affect, and time) is the kind of change that shows up in agent frameworks within a year. Build your retrieval interface so you can swap the memory backend without rewriting the agent.