All docs
Evaluation policyData definitionsBusiness rulesdashboard

Business rules

Business rules check that every answer obeys your own policy in any domain: limits, allowed values, date windows, required statements and relationships between values, with six ready-made templates for insurance, HR, healthcare, lending, refunds and legal deadlines.

What you'll have

An answer that approves more visits than your plan allows, refunds more than the order, or misses a filing window fails "Follows business rules", with the sentence that breaks the rule marked and the reason in plain words.

What it is and what it powers

Every regulated workflow has rules an answer must obey, and the rules are not in the answer and often not in the sources: they are your policy. A benefit can't exceed the plan's limit. Physical therapy beyond 12 visits needs prior authorisation. A refund is allowed only within 30 days of delivery. A response to a complaint is due 21 days after service.

Business rules state them. You declare facts, the typed values to read from each answer (approved_visits is a number, benefit is money, service_date is a date), and rules over those facts. Each answer is then checked as its own check, Follows business rules:

ResultMeaning
PassEvery rule that applied passed. A rule whose fact the answer doesn't mention at all has nothing to check and doesn't stop a pass
FailA rule is broken, and the reasoning model confirmed the answer decides that value
WarningA rule looks broken, but it could not be confirmed (shown, never counted as a failure)
Couldn't checkAt least one rule couldn't be decided, even if others passed, so a missed reading is never shown as a pass. The drawer lists why (two different values, a plan missing from a look-up table, a currency or unit that doesn't compare, a turn the reasoning model couldn't read) and how many rules passed
Not configuredThe project has no business rules

The check is not a gate until you make it one in your scoring rules. It never changes grounding: a sentence can be fully supported by the documents and still break your rule ("your plan covers 20 visits" when your rule caps approvals at 12). The sentence that holds the value is marked Breaks a business rule on the answer's claims, with the reason: "Breaks a business rule: the answer approves 16 visits; the rule allows at most 12."

How an answer is checked

  1. Each fact is read. A fact from the metadata is read by its key from what your app sends with the answer. A fact from the answer is read by its key, when the answer is JSON or has a JSON block; by its column, when the answer is a table; by its label ("visits approved: 16", "we approve 16 visits"); as the only value of its type, when only one fact of that type is still open; and last, by the reasoning model. A value the reasoning model reads counts only if it is written in the answer. When the answer says there is none of an amount or a count ("no benefit is payable", "no visits remain"), the reasoning model gives those words, and the fact is read as 0 only if they are in the answer. A value written once in the answer belongs to one fact only, and before a rule is reported broken, each value the reasoning model read for it is confirmed to be that fact.
  2. Code decides each rule. when first (the rule applies only if it holds), then unless (an exception that makes the rule pass), then the check. Dates, amounts, units and durations are compared as typed values: "4000 mg" against a limit of "4 g" passes, and 43% against "below 43%" is broken.
  3. A broken rule is confirmed before it counts. The reasoning model is asked, twice with the choices in a different order, whether the answer decides the value or only quotes, refuses, compares or supposes it. "We can't approve 16 visits without prior authorization" reads 16 visits, and the confirmation drops it. If the reasoning model can't be reached, the finding is a warning, never a failure.

Code never picks between two values. Two different values for one fact ("approve 10 visits … approve 14 visits"), a date written only as 04/03/2026 with no date order set, or a relative date ("filed yesterday") leave the fact undecided, and the rules that need it show Couldn't check with the reason. Amounts in different currencies are never converted, and "12 weeks" is not compared with "3 months".

Facts

KeyMeaning
nameLower case letters, digits and _, starting with a letter: approved_visits
typedate, number, money, quantity, percent, duration, boolean, identifier, code or string
labelsThe words the answer writes before the value. Without labels, the name with _ read as a space is the label
listtrue for several values, such as every drug prescribed: a rule applies to each value
optionsAs for hand-off fields: default_currency or currency for money, units for a quantity, date_order (DMY or MDY) for a date, code_list for a code, tolerance

| from, key | from: metadata with key: weeks_paid reads the fact from the metadata your app sends with the answer, for values only your system knows (leave taken so far, weeks already paid). A dotted key reads inside an object (claim.weeks_paid). Read in code, never by the reasoning model, and never confirmed: it is your own data |

A fact is read from the answer unless it says from: metadata. When the metadata doesn't hold the key, the rules that need the fact show Couldn't check: "metadata weeks_paid was not sent with the answer". Facts read from the sources are coming next.

facts:
  - {name: weeks_requested, type: duration, labels: ["approved for"]}
  - {name: weeks_paid, type: duration, from: metadata, key: weeks_paid}

Rules

Each rule has a name, one check, and optionally when, unless and message (your own sentence, shown after the computed one).

CheckMeaningExample
at_most / at_leastA fact against a value, another fact, a look-up table's cell, or an expression. inclusive: false makes the bound strict{fact: benefit, at_most: "USD 25,000"} · {fact: refund, at_most: {fact: order_amount}} · {fact: weekly_benefit, at_most: {table: plan_limits, column: weekly_max}} · {fact: weeks_requested, at_most: {expr: "lookup(plan_limits, max_weeks) - weeks_paid"}}
betweenTwo bounds{fact: daily_dose, between: ["1 g", "4 g"]}
one_of / none_ofAllowed or excluded values, or a code list{fact: drug, none_of: [codeine, tramadol]}
withinFrom one date fact to another, in days or weeks, or in whole calendar months or years (or a table's duration cell){within: {from: service_date, to: filed_date, at_most: "30 days"}} · {within: {from: onset_date, to: end_date, at_most: "6 months"}}
requiredThe answer must state the fact{fact: reason_code, required: true}
equalsA relationship, as an expression{fact: tax, equals: "net * 20%"} · {fact: response_deadline, equals: "service_date + 21 days"}
isA yes / no fact's value{fact: prior_auth, is: true}

Expressions in equals and in {expr: "..."} bounds use fact names, numbers, percents (20%), durations (21 days, 6 months), amounts with their currency (USD 10), + - * /, parentheses, min, max, sum, round(x, 2) and lookup(table, column), the cell of this answer's row: min(salary * 60%, lookup(plan_limits, weekly_max)). They are read by our own parser and computed exactly. tolerance says how far apart still counts as equal, in the fact's own unit (percentage points for a percent); without it, half a unit in the last place the answer writes.

Calendar months. "6 months" counts calendar months, never a number of days: a date plus 6 months is the same day of the month six months on, or that month's last day when it is shorter (31 August + 6 months is 28 February, or 29 February in a leap year). Months and days are never mixed: "12 weeks" against "3 months" shows Couldn't check, as months aren't a fixed number of weeks.

Conditions: when, unless, all and any

when and unless take a condition in the same form as a check (except required), or all / any of several, nested up to three deep:

- name: PT visits need prior authorization after the limit
  check: {fact: approved_visits, at_most: {table: plan_limits, column: visit_limit}}
  unless:
    any:
      - {fact: prior_auth, is: true}
      - all:
          - {fact: plan, one_of: [gold]}
          - {fact: diagnosis, one_of: [post-surgical]}

A condition on a fact the answer (or the metadata) doesn't state does not hold: a rule whose when names an unstated fact doesn't apply, and an exception the answer doesn't state doesn't excuse it. Two different values for a fact in a condition leave the rule Couldn't check.

Look-up tables

A table is a look-up keyed by one fact: plan → limits, product → maximum loan, drug → maximum daily dose. Each column has a type, and every cell is read as its type when you save. A rule reads the cell of the row for this answer's key, with {table, column} as a bound or lookup(table, column) in an expression.

business_rules:
  facts:
    - {name: plan, type: string, labels: ["plan"]}
    - {name: weekly_benefit, type: money, currency: USD, labels: ["weekly benefit"]}
    - {name: approved_visits, type: number, labels: ["approve"]}
  tables:
    plan_limits:
      key: plan
      columns: {weekly_max: {type: money, currency: USD}, visit_limit: number, max_weeks: duration}
      rows:
        - {plan: gold,   weekly_max: "USD 1,000", visit_limit: 20, max_weeks: "26 weeks"}
        - {plan: silver, weekly_max: "USD 600",   visit_limit: 12, max_weeks: "13 weeks"}
  rules:
    - name: Weekly benefit within the plan maximum
      check: {fact: weekly_benefit, at_most: {table: plan_limits, column: weekly_max}}

A key the table doesn't hold means the rule can't be checked for that answer, and the drawer says so ("plan bronze is not in plan_limits"): another row is never used instead. A row whose cell is left empty can't check that rule either, and says so.

Bands. With range: true, rows are bands of an ordered fact (a number, percent, amount, quantity, duration or date), each from key_from up to, but not including, key_to. Bands must follow each other with no gap and no overlap; only the last may leave out key_to.

tables:
  benefit_period:
    key: age_at_onset
    range: true
    columns: {max_period: duration}
    rows:
      - {key_from: 0,  key_to: 60, max_period: "60 months"}
      - {key_from: 60, key_to: 65, max_period: "5 years"}
      - {key_from: 65, max_period: "24 months"}

An age of exactly 60 falls in the second band. Tables are written in the policy YAML, in the JSON editor under Data definitions › Business rules, or with the SDK: there is no CSV import for them. Up to 20 tables of 5,000 rows each.

What is refused when you save

Every rule is checked when you save it, or with Check and variably policy validate, by the same rules scoring uses, so a saved definition always runs:

  • an unknown key or a near miss ("did you mean at_most?");
  • a rule naming a fact that isn't declared ("did you mean approved_visits?");
  • comparing values that can't be compared: a date against money, kilograms against metres, USD against EUR;
  • a value that doesn't read as its fact's type ("twelve-ish" for a number, "next Tuesday" for a date);
  • an expression that doesn't parse, uses a fact of the wrong type, or divides by zero;
  • two rules with the same name, and a when or unless on the fact the rule checks;
  • a table row that doesn't read as its column's type, a key in two rows, bands with a gap or an overlap, or a bound naming a table or column that isn't declared ("did you mean weekly_max?");
  • a within bound that mixes months with days, or uses business days;
  • a fact read from the sources, and totals over a list, which are coming next.

Paste this into your coding agent

Paste this into Claude Code, Cursor, or whichever agent has your repository open. Name the policy document you have; it writes the facts, rules and look-up tables and checks them with variably policy validate.

Prompt for your coding agent
Write variA/Bly business rules for this project from a policy document I have: a benefits
schedule, an underwriting guide, a refund policy, a dosing protocol. Business rules declare the
facts to read from each answer and the rules those facts must obey, and each answer is checked
against them.

Look first:
1. Ask me for the policy document if I have not named it, and read it. List each rule it
   states that an answer could break, quoting the sentence it comes from. Show me the list
   before you write anything, and leave out anything the document does not state.
2. If the app already sends values only it knows (weeks already paid, a balance) in the
   metadata of its observe() or client.log() call, note the keys.

Then write them under evaluation_config.business_rules:

evaluation_config:
  business_rules:
    facts:
      - {name: plan, type: string, labels: ["plan"]}
      - {name: approved_visits, type: number, labels: ["approve", "visits approved"]}
      - {name: weeks_paid, type: duration, from: metadata, key: weeks_paid}
    tables:
      plan_limits:
        key: plan
        columns: {visit_limit: number}
        rows:
          - {plan: gold, visit_limit: 20}
          - {plan: silver, visit_limit: 12}
    rules:
      - name: Visits within the plan limit
        check: {fact: approved_visits, at_most: {table: plan_limits, column: visit_limit}}
        message: "Policy section 4.2: visits above the plan limit need prior authorization."

- Facts: name (lower case, digits and _), type (date, number, money, quantity, percent,
  duration, boolean, identifier, code or string), labels (the words an answer writes before
  the value). from: metadata with key for values the app sends rather than the answer.
- Rules: name, one check (at_most, at_least, between, one_of, none_of, within, required,
  equals or is), optional when, unless and message. Put the document's section in message.
- A value that depends on a plan, product or tier goes in a look-up table, not in one rule per
  value.
- Start from the closest ready-made template on Evaluation policy › Data definitions ›
  Business rules if one fits. The format is described at https://www.variably.dev/docs/data-business-rules.

How to write it, as policy YAML:
1. The variably command comes with the SDK (pip install variably-sdk). It reads
   VARIABLY_API_KEY and VARIABLY_BASE_URL from the environment; never hard-code the key or write it into a file.
2. If variably-policy.yaml is not in the repository yet, run `variably policy pull`: it writes
   the version in force to variably-policy.yaml. Change only evaluation_config.business_rules in that
   file and leave every other key exactly as it is.
3. Verify: run `variably policy validate variably-policy.yaml`. It checks the file as the server would
   and saves nothing; each problem is printed as "line N: path: message". Fix every problem and
   run it again until it exits 0. Do not guess a key the error does not name: unknown keys are
   refused.
4. Run `variably policy diff variably-policy.yaml` and show me what would change.
5. Do not push or publish. Tell me the two ways to save it as a draft: paste the file into
   Evaluation policy › YAML and click Apply as draft, or run
   `variably policy push variably-policy.yaml --note "<why>"` with a key allowed to change the
   evaluation policy. A draft scores nothing until it is published.

When you are done, tell me each rule with the sentence of the document it comes from, and each
rule of the document you could not express. Verify further with Try it on the Business rules tab,
on an answer that breaks a rule and one that keeps it.

Ready-made templates

In the app, Evaluation policy › Data definitions › Business rules › Start from a template copies one of these into the editor. Nothing applies until you save it to the draft and publish. The numbers are examples, not a regulation's figures: replace these values with your own plan or policy.

Insurance claims

# Replace these values with your own plan or policy.
business_rules:
  facts:
    - {name: plan, type: string, labels: ["plan", "plan tier"]}
    - {name: benefit, type: money, default_currency: USD, labels: ["benefit", "benefit approved", "we will pay"]}
    - {name: approved_visits, type: number, labels: ["approve", "approved visits", "visits approved"]}
    - {name: prior_auth, type: boolean, labels: ["prior authorization", "prior auth"]}
    - {name: service_date, type: date, labels: ["date of service", "service date"]}
    - {name: filed_date, type: date, labels: ["filed", "submitted"]}
    - {name: enrolment_date, type: date, labels: ["enrolled", "enrolment date", "enrollment date"]}
    - {name: cover_start, type: date, labels: ["cover starts", "coverage starts", "coverage begins"]}
  rules:
    - name: Benefit within the plan maximum
      check: {fact: benefit, at_most: "USD 25,000"}
    - name: PT visits need prior authorization after the limit
      check: {fact: approved_visits, at_most: 12}
      unless: {fact: prior_auth, is: true}
      message: Physical therapy beyond 12 visits needs prior authorization.
    - name: Claim filed within 30 days of service
      check: {within: {from: service_date, to: filed_date, at_most: "30 days"}}
    - name: Cover starts at least 90 days after enrolment
      check: {within: {from: enrolment_date, to: cover_start, at_least: "90 days"}}
    - name: Plan is one we sell
      check: {fact: plan, one_of: [gold, silver]}

HR leave

# Replace these values with your own plan or policy.
# Leave already taken (weeks_taken, from your HR system) comes with phase 2.
business_rules:
  facts:
    - {name: leave_type, type: string, labels: ["leave type", "type of leave"]}
    - {name: weeks_requested, type: duration, labels: ["approved for", "weeks requested", "leave of"]}
    - {name: months_of_service, type: duration, labels: ["months of service", "employed for", "service of"]}
  rules:
    - name: Leave type is one we offer
      check: {fact: leave_type, one_of: [fmla, sick leave, parental leave]}
    - name: FMLA leave is at most 12 weeks
      check: {fact: weeks_requested, at_most: "12 weeks"}
      when: {fact: leave_type, one_of: [fmla]}
    - name: FMLA needs 12 months of service
      check: {fact: months_of_service, at_least: "12 months"}
      when: {fact: leave_type, one_of: [fmla]}

Healthcare medication

# Replace these values with your own plan or policy.
# A per-drug maximum dose (a look-up table) comes with phase 2.
business_rules:
  facts:
    - {name: drug, type: string, list: true, labels: ["prescribe", "prescribed", "medication"]}
    - {name: daily_dose, type: quantity, units: ["mg", "g", "mcg"], labels: ["daily dose", "dose"]}
    - {name: prior_auth, type: boolean, labels: ["prior authorization", "prior auth"]}
  rules:
    - name: No excluded drugs
      check: {fact: drug, none_of: [codeine, tramadol]}
    - name: Daily dose within the formulary maximum
      check: {fact: daily_dose, at_most: "4 g"}
    - name: Prior authorization stated for drugs that need it
      check: {fact: prior_auth, required: true}
      when: {fact: drug, one_of: [adalimumab, etanercept]}

Lending

# Replace these values with your own plan or policy.
# A per-product loan limit (a look-up table) comes with phase 2.
business_rules:
  facts:
    - {name: dti, type: percent, labels: ["debt-to-income", "DTI"]}
    - {name: loan_amount, type: money, default_currency: USD, labels: ["loan amount", "approved amount"]}
    - {name: monthly_debt, type: money, default_currency: USD, labels: ["monthly debt", "monthly debts"]}
    - {name: income, type: money, default_currency: USD, labels: ["monthly income"]}
  rules:
    - name: DTI under 43%
      check: {fact: dti, at_most: "43%", inclusive: false}
    - name: DTI is monthly debt over monthly income
      check: {fact: dti, equals: "monthly_debt / income", tolerance: 0.5}
    - name: Loan within the product limit
      check: {fact: loan_amount, at_most: "USD 500,000"}

Customer support refunds

# Replace these values with your own plan or policy.
business_rules:
  facts:
    - {name: refund, type: money, default_currency: USD, labels: ["refund", "we will refund"]}
    - {name: order_amount, type: money, default_currency: USD, labels: ["order total", "order amount", "you paid"]}
    - {name: delivery_date, type: date, labels: ["delivered on", "delivery date", "delivered"]}
    - {name: request_date, type: date, labels: ["requested on", "request date", "requested"]}
  rules:
    - name: Refund no more than the order amount
      check: {fact: refund, at_most: {fact: order_amount}}
    - name: Refund requested within 30 days of delivery
      check: {within: {from: delivery_date, to: request_date, at_most: "30 days"}}
# Replace these values with your own plan or policy.
# Calendar days. Court calendars and business days come with phase 3.
business_rules:
  facts:
    - {name: service_date, type: date, labels: ["served on", "date of service", "service date"]}
    - {name: response_deadline, type: date, labels: ["respond by", "response deadline", "deadline"]}
  rules:
    - name: Response due 21 days after service
      check: {fact: response_deadline, equals: "service_date + 21 days"}

Collections calls (whole conversation)

Rules with scope: session are checked over a whole conversation, turn by turn (see Rules over a whole conversation below). Each yes/no fact is read by the reasoning model from its speaker's words; the balance comes from the metadata your app sends.

# Replace these values with your own plan or policy.
# Rules over a whole conversation (scope: session): each fact is read turn by turn from its speaker's words.
business_rules:
  facts:
    - {name: dispute, type: boolean, speaker: customer, description: "the customer disputes the debt or says they don't owe it"}
    - {name: dispute_logged, type: boolean, speaker: agent, description: "the agent acknowledges the dispute and says it is logged"}
    - {name: collection_demand, type: boolean, speaker: agent, description: "the agent asks or tells the customer to pay (a payment request or demand); saying how or where they can pay, or that the call is about a debt, is not a demand"}
    - {name: hardship, type: boolean, speaker: customer, description: "the customer says they are in financial hardship (lost a job, illness, can't afford to pay)"}
    - {name: hardship_plan, type: boolean, speaker: agent, description: "the agent offers the hardship programme"}
    - {name: payment_arrangement, type: boolean, speaker: agent, description: "the agent offers or sets up a payment arrangement or instalment plan"}
    - {name: debt_disclosure, type: boolean, speaker: agent, description: "the agent says the call is an attempt to collect a debt"}
    - {name: stop_calling, type: boolean, speaker: customer, description: "the customer asks not to be called again"}
    - {name: payment_amount, type: money, speaker: agent, default_currency: USD, labels: ["payment of"]}
    - {name: balance, type: money, from: metadata, key: balance, default_currency: USD}
  rules:
    - name: No collection demand while a dispute is open
      scope: session
      check: {never_after: {fact: dispute, then: collection_demand, until: dispute_logged}}
    - name: Hardship plan before any payment arrangement
      scope: session
      when: {fact: hardship, is: true}
      check: {before: {first: hardship_plan, then: payment_arrangement}}
    - name: Say the call is an attempt to collect a debt in the first two turns
      scope: session
      within_turns: 2
      check: {fact: debt_disclosure, required: true}
    - name: No payment demand after the customer asks not to be called
      scope: session
      check: {never_after: {fact: stop_calling, then: collection_demand}}
    - name: A promised payment is within the balance
      scope: session
      check: {fact: payment_amount, at_most: {fact: balance}}

Rules over a whole conversation

Some decisions are wrong only in light of something said earlier. A customer mentions hardship in turn 3, and in turn 9 the agent offers a payment arrangement without the hardship plan. Each turn on its own looks fine; the conversation breaks the rule. A rule with scope: session is checked over the session's turns, in order. A turn is one customer message and the agents' work up to the reply the customer receives.

Who the customer is. In a conversation with one agent, each event is a turn: its input is what the customer said and its response is what the agent answered. When several agents work on one message (a triage agent handing off to a collections agent, or an assistant calling a helper), only the first agent's input is the customer's words. What one agent passes to another is agent words, never the customer's: a triage note that says "customer may be in hardship" is not the customer disclosing hardship. The agent's words are the reply the customer receives at the end of the turn. variA/Bly works out which agent comes first from the hand-offs and calls your steps record, the same links the agent graph shows.

facts:
  - {name: hardship, type: boolean, speaker: customer}
  - {name: hardship_plan, type: boolean, speaker: agent}
  - {name: payment_arrangement, type: boolean, speaker: agent}
  - {name: dispute, type: boolean, speaker: customer}
  - {name: dispute_logged, type: boolean, speaker: agent}
  - {name: collection_demand, type: boolean, speaker: agent}
  - {name: debt_disclosure, type: boolean, speaker: agent}
  - {name: payment_amount, type: money, speaker: agent, default_currency: USD, labels: ["payment of"]}
  - {name: balance, type: money, from: metadata, key: balance, default_currency: USD}
rules:
  - name: Hardship plan before any payment arrangement
    scope: session
    when: {fact: hardship, is: true}
    check: {before: {first: hardship_plan, then: payment_arrangement}}
  - name: No collection demand while a dispute is open
    scope: session
    check: {never_after: {fact: dispute, then: collection_demand, until: dispute_logged}}
  - name: Say the call is an attempt to collect a debt in the first two turns
    scope: session
    within_turns: 2
    check: {fact: debt_disclosure, required: true}
  - name: A promised payment is within the balance
    scope: session
    check: {fact: payment_amount, at_most: {fact: balance}}

These rules are an illustration of what a collections team might write, not a statement of any regulation. Replace them with your own policy.

Who said it. speaker on a fact says whose words it is read from: customer, agent or any (the default). A dispute the agent describes ("if you dispute this debt, we pause collection") is not the customer disputing. A fact read from the customer can only be used by a rule with scope: session, since one answer holds only the agent's words.

Reading, turn by turn. Each fact is read from each turn separately, in the same way as for one answer, and the reasoning model reads only that turn's words. Each value it reads must be written in that turn. The result is a timeline: which fact was said, in which turn, by whom, and how it was read. A long conversation is read turn by turn, never as one large text.

Latest value wins. A condition such as when uses each fact's latest value as of the turn being checked. A customer who says they are in hardship and later says they no longer are has taken it back: a yes/no fact's later "no" replaces an earlier "yes" only when the same speaker says it in their own written words.

The session checks.

  • before: {first: A, then: B}: wherever B happens, A happened in that turn or an earlier one. The hardship plan offered in the same message as the arrangement counts as before it.
  • never_after: {fact: A, then: B, until: C}: once A has happened, B doesn't, unless C happened after A and by B's turn. A second dispute needs its own acknowledgement. until is optional.
  • required with within_turns: N: the fact is stated within N turns, counting from the turn where the rule's when starts to hold (or from the first turn). Without within_turns, by the end of the conversation.
  • Every other check (at_most, one_of, is and the rest) applies at each turn that states its fact, with the other facts' latest values.

A yes/no fact "happens" in a turn when it is said as yes; any other fact happens when it is stated. A step can also be a condition, such as then: {fact: payment_amount, at_least: 100}.

Before a rule counts as broken. Code decides every rule. Before a broken rule counts, the reasoning model reads the deciding turn with the few turns before it. It checks whether the agent committed to the action there (offered, demanded, promised) or only mentioned, refused or explained it. "I can't set up a plan until your dispute is resolved" is a mention, not an offer. If it was only mentioned, the finding is dropped with a note and the next place the rule may be broken is looked at. If the model can't confirm it, the rule shows as a warning, never a failure.

Where it shows. The session's page in Sessions has a Business rules card: a summary line, the number of turns read, and a table of Rule, Verdict and What happened. The verdicts are Holds, Broken, Broken? Not confirmed (a warning: the reasoning model could not confirm it) and Mentioned, not committed (the agent only mentioned, refused or explained it there: not counted). What happened lists the turns the verdict rests on, for example "Turn 3 · customer · hardship — “I lost my job last month” (what came first)" and "Turn 9 · agent · payment arrangement (what followed)". A broken rule has an Open turn 9 button that opens the event of the turn that decided it. The session's checks include Follows business rules (whole conversation), which your policy can make a gate. Rules that never applied in a conversation are counted under the table ("2 rules did not apply to this conversation."), not listed.

On the turn that broke it. A broken rule is also shown on the event of the turn that decided it. That event gets a new verdict: the sentence holding the value carries Breaks a business rule, and its Follows business rules lists the rule. If no sentence holds the value (for example, something that was never said), the rule shows in that check only. Grounding scores do not change. The earlier verdict is kept: the event's History tab shows both, the earlier one as On arrival and the new one as Whole conversation, with a line saying which rule and session. The new one is Shown now. Checking the session again with the same result adds nothing; a different result replaces the session's verdict on that event.

When it runs: ending a conversation. The rules are checked when the conversation ends, the same as the other session checks. Tell variA/Bly a conversation has ended in one of two ways:

  • call client.end_session(session_id) when it is over (for example, when a call hangs up; Python SDK 2.18.0 or later). The checks over the whole conversation run then. Calling it again is safe: it answers that the session was already ended and runs nothing twice. A session id with no logged step is refused with the reason.
  • or mark the last step you log as the final step (is_aggregator=True), as before.

Nothing is guessed from idle time. Facts read from the metadata use the metadata of the last step logged. With Try it, you can paste a conversation as "Customer: …" and "Agent: …" lines to see the verdict.

In the app, step by step

Data definitions: Business rules (Collections template) and Try itData definitions: Business rules (Collections template) and Try it

  1. Open Evaluation policy › Advanced settings ▸ › Data definitions › Business rules. The table lists your rules (Rule, Check, Only when, Unless); with none, it says "No business rules yet: the check shows Not configured."
  2. Under Facts & rules, choose Start from a template (for example Insurance claims or Collections calls (whole conversation)), or type your own. The box takes the rules as JSON: the same facts and rules as the YAML on this page, written with braces and quotes. The JSON, key by key, beside it, explains every key.
  3. Replace the template's values with your own plan's or policy's.
  4. Click Check: every fact and rule is checked as saving would, and nothing is stored. A problem is named ("did you mean at_most?").
  5. Use Try it with a real answer (and, for conversation rules, a pasted conversation) to see each rule's verdict before you save.
  6. Click Save to draft, then publish the draft. Answers that arrive afterwards are checked; to check earlier ones, re-score them.

The same rules in JSON, as the editor takes them:

{
  "facts": [
    {"name": "approved_visits", "type": "number", "labels": ["approve", "visits approved"]},
    {"name": "prior_auth", "type": "boolean", "labels": ["prior authorization"]}
  ],
  "rules": [
    {"name": "Physical therapy visits within the limit",
     "check": {"fact": "approved_visits", "at_most": 12},
     "unless": {"fact": "prior_auth", "is": true},
     "message": "Beyond 12 visits needs prior authorization."}
  ]
}

What you'll see

The answer saysFollows business rulesOn Claims
"We approve 10 physical therapy visits."Pass: the rule applied and holdsnothing extra
"We approve 16 physical therapy visits."Fail: "the answer approves 16 visits; the rule allows at most 12", then your message "Beyond 12 visits needs prior authorization."The sentence carries Breaks a business rule
"We approve 16 visits, as prior authorization is on file."Pass: the unless exception holdsnothing extra
"We can't approve 16 visits without prior authorization."Pass: the answer mentions 16 visits but doesn't decide it (it refuses), so it doesn't break the rulenothing extra
"Your therapist will be in touch."Couldn't check: the visits aren't stated, so no rule could be decided; the drawer says which fact was missingnothing extra

The rule's verdict and the facts read are in the Business rules section under the Checks table.

Common mistakes

MistakeWhat happensFix
Labels that don't match how your answers are writtenThe fact isn't found: Couldn't check, "not stated"Add the words your answers use before the value to labels; Try it shows how each fact was read
A limit written as text ("twelve")Refused when you save: a value must read as its fact's typeWrite 12
Money without a currency in a multi-currency businessAmounts in different currencies are never compared: Couldn't checkSet default_currency or currency on the fact
A conversation rule without scope: session, or a customer fact used in an answer ruleRefused when you saveAdd scope: session to rules that use customer facts
Never ending conversationsRules over a whole conversation never runCall client.end_session(session_id) when it is over
Expecting a broken rule to lower groundingGrounding is unchanged: the rule is its own checkMake Follows business rules count where you need it (alerts, experiment guardrails, review queue rules)

Try it

Try it, under the editor, runs the same check scoring runs on one answer you paste (and, for rules with scope: session, on a conversation you paste), with the metadata your app would send (as JSON) when a fact is read from it: every rule that applied with its verdict, each fact read and how it was read (key, column, label, only value, the metadata, or the reasoning model), the look-up tables each rule used, and why a rule couldn't be checked. A rule broken only by values from the metadata shows that nothing needed confirming: it is your own data, not something the answer decided. It uses the draft's rules (else the version in force). Nothing is stored or scored.

In the answer's drawer

Checks shows Follows business rules with its result, and below the table a Business rules section lists every rule that applied, its verdict and the facts read. Rules whose when did not hold are counted, not listed. On Claims, the sentence that holds a confirmed broken value carries Breaks a business rule.

In YAML

The examples above, under evaluation_config.business_rules. Check a file without saving it with variably policy validate FILE.

From the SDK

client.set_business_rules(experiment_id, "settings/business_rules.yaml", note="visit limit 12")

The file may hold the rules under a top-level business_rules key, as the templates do. On a project scored by its evaluation policy this publishes a new policy version with only the business rules changed. The API key needs the scope policy.write. From CI: python -m variably.settings push --experiment-id EXP --business-rules business_rules.yaml --note "...".


Concepts on this page: Data definitions