Skip to main content

Policy

A policy is one thing an org's agents must keep to: what it checks, what happens then, and what it says.

It is about the business, not about the platform: "an amount is at or over the limit", "an email goes to someone outside the org", "a document contains a social security number". It is decided outside the model, before the thing it guards happens.

Why it exists​

Telling a model "never send more than $25,000" is a request. A policy is a control: the call is put to a policy engine before it runs, and the model's opinion is not asked. It also lets an org write its own credit policy and approval limits once, in words its people can read, and apply them to many agents.

An example​

A policy from the Platform, whole. This is the file the product ships.

policy.yaml
title: Approve calls over an amount
summary: A call whose amount, with the run's earlier ones, is at or over a limit waits for a person.
kind: needs_approval
when: [before_tool]
category: General
person: The amount is at or over the limit, so a person approves it first.
agent: The amount is at or over the approval limit. A person approves this call first; wait for the answer.
values:
- {key: tools, label: Tools, type: list, default: []}
- {key: argument, label: Amount argument, type: text, default: amount}
- {key: threshold, label: Limit, type: number, default: 25000}
- {key: currency, label: Currency, type: text, default: USD}

Its check, in Rego. It returns what it found, never what should happen:

check.rego
# At or over the limit, with what this run already sent to the listed tools, so
# an amount split across calls is seen whole.
found contains {"what": sprintf("%v %s, at or over %v", [total, v.currency, v.threshold]), "where": v.argument} if {
lib.called(v.tools)
same_currency
total := abs(amount) + earlier
total >= v.threshold
}

# No readable amount, or another currency: the check does not guess.
found contains {"what": sprintf("no readable %s", [v.argument]), "where": v.argument} if {
lib.called(v.tools)
not amount
}

And its tests. Each is one situation with what the policy should do with it: act, or do nothing. Each runs in CI:

cases.yaml
- name: A payment over the limit
values: {tools: [bank.pay]}
input: {tool: bank.pay, arguments: {amount: 40000, currency: USD}}
expected: acts
- name: A payment under it
values: {tools: [bank.pay]}
input: {tool: bank.pay, arguments: {amount: 5000, currency: USD}}
expected: nothing

How it works​

Two moments​

Decided here
Writing it (once)Its name, kind, check, when it acts, both messages, the values it takes, its tests
Applying it (each time)The values for this use, the agents it covers, the kind's one setting, in force or on trial

A policy does nothing until it is applied, and it can be applied more than once with different values.

Kinds​

KindWhen its check finds somethingWaits on a person
Needs approvalIt waits until a person approvesAlways
Sends backThe agent is told what to fix. It does not go on until it is fixedWhen the tries run out
FixesThe policy changes it and lets it go on. The agent is not askedNever
HidesValues are masked or removed before they are seenNever

Fixes is designed and not yet available: no policy of that kind can be made today.

Moments​

A policy acts at one or more of five moments: before a tool runs, after a tool returns, before the model reads, before work is handed in, before the answer is sent. Which kind may act at which moment is one table, in Reference.

Two messages​

Every policy says one sentence to a person, in real-world words, and one to the agent, about what to do next. Why a person is asked is always shown as the policies that asked, by name.

Platform and org​

A policy is from the Platform when it came with the product: an org applies it with its own values and cannot change it. It is from the Org when somebody in the org made it, or copied one and changed it. Both are in one list and read the same way.

Hiding​

A policy that hides finds a value by its shape (a card number in an email) or by the field it is in (Tax ID on a record). What is left in its place is a setting: nothing, its name ([Social security number]), or its last four (****6789). The model, and the provider behind it, never receives the value.

States​

Of an application:

StateMeaning
In forceIt decides, and what it decides happens
On trialIt decides as it would and records what it would have done. It holds nothing

What always holds​

  • A check returns what it found. The kind decides what happens.
  • No kind simply refuses. A policy that must stop something sends it back with what to do instead, so the agent always has a next step.
  • An approval is for one call. Never the next identical one.
  • Sent back comes before asked. A person is not asked about something a policy will send back anyway.
  • No decision means no call. If the engine cannot answer, the call is not made.