Founders

How to Write a Decision Rule an Agent Can Follow

Antonio Evans9 min read

A split scene: on the left, a founder sketching a flowchart on a whiteboard with boxes labeled 'trigger', 'condition', 'action', 'exception'; on the right.
Key points

Key points

  1. 1A dependable agent rule has four parts: a trigger event, a measurable condition, a specific action, and explicit exceptions.
  2. 2Vague words such as "significant" or "reasonable" cannot be tested, so replace each one with an observable threshold and a named evidence field.
  3. 3A rule is only as good as its exceptions and its fallback route, because the cases you did not write down are where agents improvise.
  4. 4Before trusting the agent, run a fixed set of edge cases through it and score whether every run produces the same decision, not just one run.

Start from a decision, not a topic

Most agent failures begin with a rule that names a subject instead of a choice. "Refunds" is a topic. "Approve a refund request under $100 for a purchase made in the last 30 days" is a decision, because you can check whether the agent got it right.

Decision-rights work in organizations makes the same point. A matrix should list "a repeatable decision class narrowly enough that its boundary can be tested," rather than broad labels such as operations or pricing, according to Evan D'Souza's guide to decision-rights matrices for founder-led startups. That advice transfers directly to prompts. If you cannot describe the boundary in measurable terms, the model will invent one.

A useful exercise is to pull the last twenty times a founder or senior operator made a judgment call and someone else waited. Common examples are refund approvals, non-standard discounts, credits for a service failure, and escalation when a customer threatens to churn. Each of those can usually be reduced to numbers and named fields.

The Educo decision rights matrix guide recommends naming a single decision owner, laying out required input, and stating the boundaries within which that owner can act without further permission. An agent is a decision owner with the same needs: one job, required inputs, and a boundary.

The practical test: if two competent people reading your rule would make different calls on the same case, the rule is not finished. Keep tightening until they agree.

The four-part conditional

Every rule an agent can execute reliably has the same skeleton:

PartQuestion it answersRefund exampleDiscount example
TriggerWhat event starts the decision?A customer requests a refundA sales rep asks to apply a non-standard discount
ConditionWhich measurable facts must hold?Purchase within 30 days and amount under $100Deal value under $25,000 and margin stays above 30 percent
ActionWhat exactly should happen?Approve automaticallyApprove the discount
ExceptionWhat overrides the action?Product marked final sale, or prior refund on the same orderCustomer is on a strategic-accounts list, or a payment term extension is also requested

Two design notes matter more than the table suggests.

First, the condition must reference fields the agent can actually see: order date, order total, product flags, account tier, margin. If the condition depends on a value that is not in the input, the model will guess, and guesses are not consistent. Decision-rules documentation for LLM-based agents describes this as the model reasoning over input and returning a typed, structured response every time the rule runs, and it warns that logic expressible as explicit conditions is better served by a deterministic table or tree than by a model at all (DecisionRules AI agent documentation).

Second, the exception should point somewhere. "Unless the product is final sale" is weaker than "unless the product is flagged final sale, in which case deny and cite the policy name." An exception without a destination is a pause, and a pause in an agent usually becomes improvisation. Guidance on agent exceptions puts the same principle plainly: the agent may reason about a case, but business rules should come from authorized sources, not from the model itself (this practitioner answer on keeping agents from inventing rules).

Worked example: the refund rule in full

When a customer requests a refund (trigger), if the order was placed within the last 30 days and the order total is under $100 (condition), approve the refund (action). If the product is flagged final sale, deny the refund and cite the final-sale policy. If the order total is $100 or more, or the customer has already received a refund on this order, do not decide: return escalate with the reason.

Notice what the rule refuses to do. It does not approve large refunds, and it does not deny them either. It routes them to a person, which is a decision the agent can make correctly 100 percent of the time.

From rule to prompt

The prompt should state the rule word for word and constrain the output. Three elements do the heavy lifting: a verbatim rule, an input schema, and a strict output format.

You are a refund decision function. Apply the rule exactly as written.
Do not use judgment outside the rule. If a case is not covered, output escalate.

RULE:
When a customer requests a refund, if the order was placed within the last
30 days and the order total is under $100, approve.
If the product is flagged final sale, deny and cite the final-sale policy.
If the order total is $100 or more, or the customer has already received a
refund on this order, escalate.

INPUT FIELDS:
order_date (YYYY-MM-DD), today (YYYY-MM-DD), order_total (USD number),
final_sale_flag (true/false), prior_refund_on_order (true/false), request_text

OUTPUT (JSON only, no other text):
{"decision": "approve" | "deny" | "escalate", "reason": "<one line>"}

This shape follows the design guidance in OpenAI's practical guide to building agents, which treats an agent as a model, a set of tools, and explicit instructions and guardrails, and which recommends prototyping with the most capable model to establish a performance baseline, then trying smaller models to see whether they hold up. The instructions field is where the rule lives; the schema is what makes the output machine-checkable.

Two phrasing habits pay off immediately.

Put the rule before the data and the output format after it. Models follow instructions more reliably when the rule is not buried between input fields.

Say what to do with missing data. If order_date is null, the rule above says nothing, and the model will fill the gap. Add one line: "If any input field is null, output escalate with reason missing_field." Then add a test case for it.

A note on tools: agents get more consistent when they fetch context with tools instead of carrying it in the prompt. The Linear Agent team described the biggest mistake in agent building as over-prompting, and advised giving the agent tools to load context rather than pasting all the context in (this conversation with the Linear Agent builders). For a refund rule, that means a tool that fetches order history rather than a prompt stuffed with customer records.

Keep the model out of the rule

A decision that can be written as explicit conditions should stay deterministic. Reserve the model for the part that resists a table: reading a free-text complaint to extract the requested remedy, or judging whether a customer narrative describes a genuine service failure.

The comparison is worth putting in front of your team:

NeedBetter toolWhy
Apply fixed thresholds to structured fieldsDecision table or codeFully deterministic, row-level audit trail
Extract the requested remedy from messy textLLMHandles ambiguity and language
Combine bothLLM extracts, code decidesKeeps the threshold arithmetic checkable

The DecisionRules comparison makes the tradeoff explicit: decision tables and trees are fully deterministic with full row-level or branch traces, while LLM-driven agents are probabilistic and best for reasoning, scoring, and extraction (DecisionRules documentation). That is not an argument against agents. It is an argument for keeping the arithmetic in code and the language understanding in the model.

A worked split for refunds: the agent reads request_text and outputs a structured requested_remedy field (refund, partial refund, store credit, unspecified). A short function then applies the 30-day and $100 thresholds to that field plus the order record. The model never evaluates a date difference, which is exactly the kind of operation where it will occasionally slip.

This also shrinks the eval surface. You only need to test the model on extraction and edge-case classification, and you test the threshold logic with ordinary unit tests.

Build the eval set

An eval set is a fixed list of cases with expected outputs, run repeatedly. For a single rule, twenty to forty cases is often enough to expose the gaps, provided the cases are chosen to attack the rule rather than flatter it.

Build the set in four layers:

  • Happy paths. Three to five ordinary approvals and denials, one per action. These catch regressions in the basics.
  • Boundary cases. The day 29, day 30, and day 31 orders; totals of $99.99, $100.00, and $100.01. Boundaries are where off-by-one reasoning shows up.
  • Exception cases. Final-sale products, repeat refunds on the same order, orders that trigger two exceptions at once. The double-exception case is the one most rules fail to specify, so write the precedence explicitly: safety exceptions beat commercial ones, and any conflict escalates.
  • Garbage cases. Missing fields, dates in the future, negative totals, a request text that contradicts the structured data. Every one should produce escalate, never a guess.

Then score consistency, not just correctness. A single run that passes tells you little. Splunk's guide to agent evaluation frameworks distinguishes pass@k (at least one of k runs succeeds) from pass^k (every one of k runs succeeds) and reports that one computer-use agent reached roughly 78 percent pass@10 but only about 36 percent pass^10. Your customers experience the second number. For a rules agent, run each eval case five times and require the same decision in all five.

Track two failure counts separately:

  1. Wrong decision: the agent returned a valid action that the rule says is wrong. This is a rule or input problem.
  2. Inconsistent decision: the agent returned different actions across runs of the same case. This is usually a wording problem, often a vague word or an unstated precedence between two exceptions.

The second count is the more informative one for prompt work. If a case flips between approve and escalate, you have found ambiguity in your own rule, not a model defect.

Close the loop by converting every production surprise into a permanent case. Splunk's framework calls this turning production incidents into regression tests so the same failure cannot reach users again (Splunk). A rule that grows from twenty cases to sixty over a few months is a rule that has met reality.

Escalation and the fallback route

The escalate branch deserves its own design, because it is the part of the rule that keeps a wrong decision from leaving the building.

Three things must be true of every escalation:

  • A named owner. "Escalate" without a destination is a notification that goes nowhere. Escalation studies note that a rule is unfinished if you cannot name who acts when the first owner is silent, and recommend writing the fallback route before the primary route (Neota Logic on governed escalation workflows).
  • A time expectation. A decision owner and a response clock should accompany every trigger, so a stalled escalation is visible rather than quiet (Neota Logic).
  • Thresholds set from evidence. Thresholds that are too low flood senior people with routine cases and train them to ignore the queue, which the same escalation analysis lists as a recurring failure mode (Neota Logic).

For the refund rule, that means: escalate returns go to the support lead queue with a four-hour clock during business hours, and to an on-call backup after that. The agent outputs the reason code, and the queue sorts on it.

Escalation thresholds should be reviewed with actual volume. If escalate is firing on 40 percent of cases, either the condition is too narrow or the threshold is set below the team's risk appetite. Both are fixable with numbers, which is the point of writing them down.

A short checklist before you ship

Run through this list for every rule you draft. It takes ten minutes and catches most of the failure modes above.

CheckPass condition
Decision is named as a choice, not a topicYou can write an expected output for one example
Every condition references an input fieldNo condition depends on knowledge outside the input
Every vague word is replacedNo "significant", "reasonable", "urgent", "large"
Every exception has a destinationDeny-with-reason or escalate-with-owner, never a pause
Exception precedence is statedConflicting exceptions resolve to escalate
Missing data is handledNull input produces escalate
Output is typedA schema a parser can read without cleanup
Boundary cases existDay 29, 30, 31 and the exact threshold values
Consistency is measuredFive runs per case, identical decisions
Fallback route is namedOwner and response clock for every escalation

If you are running several rules across different models, a single API for text, vision, and structured tasks keeps the plumbing out of the way; Quanta Inference exposes many model families behind one OpenAI-compatible key, which makes swapping the model under a rule a configuration change rather than a rewrite.

FAQ

FAQ

What is the difference between a rule and a prompt?

A rule is the decision logic: trigger, condition, action, exception. A prompt is one implementation of that rule, and it should quote the rule verbatim plus define the input fields and the output schema. Keeping them separate lets you change models without renegotiating the policy, and lets you review the policy without reading prompt engineering.

How many eval cases do I need for a single rule?

Twenty to forty well-chosen cases usually expose the structural gaps, provided they include boundaries, double exceptions, and malformed input. The number that matters is coverage of the ways the rule can break, not raw count. Grow the set every time production surprises you.

What should the agent do when two exceptions apply at once?

Escalate. Write the precedence into the rule so this is a deliberate choice rather than a coin flip. A common pattern is that safety or legal exceptions override commercial ones, and any conflict between two commercial exceptions goes to a person.

Should the agent ever apply judgment outside the written rule?

No. The safe behavior for an unknown case is to stop, record the context, and route it to a person, who then decides whether the rule needs to change. The agent can reason within the rule, but business rules should come from authorized people, not from the model.

Can a smaller or cheaper model run the same rule?

Often yes, but only after you have a baseline. Start with the most capable model to establish accuracy, then swap in smaller models and rerun the same eval set. Keep a smaller model only if it holds the same decisions on every case, including the boundary and exception ones.

Sources

Sources

  1. Decision Rights Matrix for Founder-Led Startups - Evan D'Souza
  2. Delegation and Decision Rights Matrix | Educo blog
  3. AI Agent
  4. How to keep an AI agent from inventing its own rules when ...
  5. A practical guide to building agents
  6. 5 Rules for Building AI Agents That Work in Production
  7. How to Build an Agent Evaluation Framework for ...
  8. Governed Escalation Workflows End Stalled Work for GCs ...
About the author

About the author

Antonio Evans
Antonio Evans

Antonio Evans is the founder of Quanta Intelligence and a fractional CTO who builds HIPAA-ready AI systems for health and life-science companies. Before that he was technical co-founder of FriendsEAT for twenty years, CEO of Socialdraft, and a data engineer at IBM. Antonio lives with his dog Santino in Lisbon, Portugal.

All articles