Skip to content
AI.info

AI agents

Deterministic Control and Model Judgment

Combine model decisions with explicit state machines, validators, and deterministic components.

By the end you can

Visual

Ownership splits at the state transition and the human gate

Every hybrid workflow alternates between a deterministic guard, model judgment, a typed boundary, and a state transition. Ownership splits at the state transition and the human gate. So do the tests.

The five stages below are not a diagram of good intentions. Each one has a published number attached to it in this lesson. A CVE severity score for a guard that lived only in prose. A task-success gap for control flow moved into code. An attack success rate for a tool list that was simply made shorter. An accuracy drop for a typed boundary tightened around a judgment step.

FigureProcess · 5 steps
  1. 1

    Deterministic guard

    A rule that must hold for every valid transition.

  2. 2

    Model judgment

    A bounded choice where language or ambiguity matters.

  3. 3

    Typed boundary

    A schema connecting model output to code.

  4. 4

    State transition

    A durable update accepted only after validation.

  5. 5

    Human gate

    An explicit transfer of authority for consequential choices.

Example

CVE-2025-32711: the guard lived in the prompt, and the prompt lost

A guard that lives in a prompt can end up catalogued as a vulnerability. This one did. CVE-2025-32711, “M365 Copilot Information Disclosure Vulnerability”, was published on 11 June 2025, assigned by Microsoft itself. The record describes the flaw in one line: “Ai command injection in M365 Copilot allows an unauthorized attacker to disclose information over a network.”

The severity is not marginal. The CVSS v3.1 base score is 9.3, Critical. NVD's own analyst score for the same record is 7.5, High. This is the shape this lesson is about, shipped, patched and filed. Untrusted incoming content reached an assistant that had data access. The only thing standing between the two was instructions written in prose. The model followed the injected instruction instead. Nothing was misconfigured. The control was simply stored in the one place an attacker gets to write to.

  • Decision at stake: Combine model decisions with explicit state machines, validators, and deterministic components. CVE-2025-32711 forced Microsoft to retrofit that split on 11 June 2025 rather than design it in.
  • Hidden assumption: All workflow logic should be moved into the model for flexibility. CVSS v3.1 prices that assumption here at 9.3, Critical; NVD scores the same record 7.5, High.
  • Primary control question: A model cannot be the sole enforcer of a rule it is also asked to interpret. The vulnerability class on the record is command injection into an assistant reading network-delivered content.
  • Evidence to collect: Mandatory controls remain effective under prompt variation. A catalogued disclosure vulnerability is the evidence you get when nobody collected that in advance.

Separation does not remove model risk, it prices it

Hybrid orchestration reserves the model for interpretation, ranking, drafting, or choosing among bounded alternatives. Code and workflow state enforce invariants, permissions, irreversible transitions, and required evidence. This separation does not remove model risk. It makes the consequences of model variability visible, and limits where that variability can reach.

CaMeL is what that looks like when someone measures it. Ten authors published it in March 2025. The design rule is one sentence of the abstract: “To operate, CaMeL explicitly extracts the control and data flows from the (trusted) query; therefore, the untrusted data retrieved by the LLM can never impact the program flow.” A trusted layer derives the plan from the user's query first. The model meets untrusted data only after that.

The bill arrives with the guarantee. CaMeL solves 77% of AgentDojo tasks with provable security against prompt injection. The same agent, left undefended, solves 84%. Seven points of utility, paid once, for a security property enforced by code instead of argued for in a prompt.

77% against 84% is the real trade: seven points of task success is what the guarantee cost, and the guarantee is the part a rewritten prompt cannot reach.

Case

JSON mode could not enforce the schema it was handed

One class of invariant has already moved out of the prompt and into the decoder. Microsoft's documentation for structured outputs draws the line between the two generations: “Structured outputs make a model follow a JSON Schema definition that you provide … This approach contrasts with the older JSON mode feature, which guaranteed valid JSON but couldn’t ensure strict adherence to the supplied schema.”

Read that as a statement about where an invariant lives. JSON mode guaranteed that the bytes would parse. That is a property of the decoder. Adherence to your schema stayed a property of the instruction, which is to say a request. Structured outputs move it into generation itself, where no wording can talk it out.

Case

Strict mode holds the shape, and the shape moves the answer

Tool calls have the same switch. Anthropic's documentation is one sentence long on the point: “Add strict: true to your custom tool definitions to ensure Claude’s tool calls always match your schema exactly.” Shape is now enforced. Meaning still is not. And the enforcement is not free.

A 2024 paper measured the price. For gpt-4o-mini-2024-07-18, GSM8K exact match fell from 94.57 in free natural language to 86.95 under JSON-mode, and to 91.71 with JSON-Schema. Last Letter Concatenation fell from 83.11 to 76.00. The mechanism turned up when the authors read the failures: “Upon inspection, we found that 100% of GPT 3.5 Turbo JSON-mode responses placed the "answer" key before the "reason" key, resulting in zero-shot direct answering instead of zero-shot chain-of-thought reasoning.”

A schema that fixes the order of keys fixed the order of thinking. The boundary held perfectly. It quietly degraded the judgment it was wrapped around. That is the failure a passing schema validation cannot show you.

Comparison

Contrasting implementations of hybrid orchestration

Prompt-only control, hybrid control, and fully deterministic control put the invariant in three different places: in the wording of the instruction, in the code wrapped around the model, or in the code alone. The test that separates them is simple. Reword the prompt, or just run it again, and see whether the rule still holds.

That test has a name and a published number. τ-bench introduced pass^k in 2024 — the chance that all k i.i.d. trials of a task succeed, averaged across tasks. Its abstract states the result: “Our experiments show that even state-of-the-art function calling agents (like gpt-4o) succeed on <50% of the tasks, and are quite inconsistent (pass^8 <25% in retail).” In figures: the GPT-4o function-calling agent reached 61.2% pass^1 in the retail domain and 35.2% in airline, 48.2% on average. At pass^8 in retail it falls below 25%.

Same agent, same policy document, eight runs. The task came out right every time in fewer than a quarter of cases. Prompt-only control is not weak because someone worded it badly. It is weak because it is re-decided on every run. pass^k is how you watch that happen.

FigureComparison · 3 columns

Prompt-only control

Policy is described in instructions to the model.

  • Easy to change
  • Weak enforcement
  • Hard to prove

Hybrid control

The model proposes; deterministic code validates and transitions.

  • Good balance
  • Auditable boundaries
  • Supports fallback

Fully deterministic control

No model selects actions or transitions.

  • Maximum predictability
  • Best for stable rules
  • Limited language flexibility

Key idea

A model cannot be the sole enforcer of a rule it is also asked to interpret

When policy and untrusted content share the same context, the model may follow the wrong instruction or rationalize an exception. A peer-reviewed paper named the problem in 2023. Its claim is structural, not incidental: “We argue that LLM-Integrated Applications blur the line between data and instructions.” The authors demonstrated working attacks against real deployed systems, including Bing's GPT-4 powered Chat. Retrieved content, they showed, can act as arbitrary code execution and control whether and how other APIs are called.

The US federal taxonomy now carries it with an identifier. NIST AI 100-2e2025, published in March 2025, classifies indirect prompt injection as attack ID NISTAML.015. It attributes the attack to generative models combining the data and instruction channels. Its guidance does not ask for better instructions: “Because current mitigations do not offer full protection against all attacker techniques, application designers may design systems with the assumption that prompt injection attacks are possible if a model is exposed to untrusted input sources, such as by using multiple LLMs with different permissions [145, 405] or by allowing models to interact with potentially untrustworthy data sources only through well-defined interfaces [410].”

That is the architecture instruction, and it comes from the standards body. Assume it lands. Encode non-negotiable controls outside the model. Expose only valid actions for the current state.

Anything the model can be argued out of was never a control; it was a suggestion with good formatting.

Steps

Partition one workflow by responsibility

Take one workflow and divide it by who is responsible for what. Mark which steps hold an invariant and which genuinely need judgment. A good split shows two things: where you have been asking the model to interpret a rule and police it at the same time, and where the rule is enforced by code that does not care how the request was phrased. Keep both lists.

The adversarial step at the end already has a public harness, and the harness has a size. AgentDojo is an adversarial test environment of 97 realistic agent tasks and 629 security test cases across four environments: Workspace, Slack, Travel Agency and e-banking. The defence that performed best in it is also the least clever available. Restrict which tools the agent may call at all. The paper reports it in one line: “Our simple tool filtering defense is particularly effective, lowering the attack success rate to 7.5%.”

The stated limit belongs on your list next to the result. Tool filtering fails for the 17% of test cases where the tools needed to do the job are also sufficient to carry out the attack. So 7.5% is the payoff for exposing only valid actions for the current state. The 17% is the size of the residue that marking invariants and guarding transitions has to cover, because no shorter tool list will.

FigureProcess · 5 steps
  1. 1

    Mark invariants

    Identify conditions that must never be bypassed.

  2. 2

    Locate semantic judgment

    Find steps that require interpretation of language or incomplete evidence.

  3. 3

    Design typed proposals

    Constrain model outputs to a small set of valid decisions.

  4. 4

    Implement transition guards

    Reject actions that violate state, policy, or authorization.

  5. 5

    Test adversarial cases

    Try urgent, persuasive, and conflicting instructions against the boundary.

Put enforcement where a rewritten prompt cannot reach it

Do not ask only whether the model can perform the task. Ask which part benefits from judgment. Keep the invariant parts outside the model.

The measurements in this lesson all point the same direction, and they point with different instruments. A control that lived in prose was catalogued as CVE-2025-32711 at CVSS v3.1 9.3, Critical. A control moved into extracted control flow cost seven points of task success — 77% against 84% — and returned provable security against prompt injection. A control implemented as a shorter tool list brought attack success down to 7.5%, and stopped covering 17% of cases. A policy carried in the prompt and rerun eight times held below 25% pass^8 in τ-bench retail. And where the boundary was tightened around a judgment step, GSM8K exact match moved from 94.57 to 86.95.

So put the enforcement somewhere a rewritten prompt cannot reach. Keep the model on the steps where interpretation is the actual work. Expect to pay for the separation in points of utility, rather than pretending it is free.

Splitting the work badly costs twice: judgment spent on steps that never needed it, and invariants left somewhere an argument can reach them.

Key takeaways