# Behavioural baseline

> Record what an agent does during a window you start, review the report, and let Thoth propose rules. A person approves; nothing switches an agent to enforce.

Source: https://docs.atensecurity.com/docs/operations/behavioural-baseline

A behavioural baseline is a record of what one agent did during a learning window that **a person
started**: which tools and action classes, in which shape, after which earlier calls in the same
session, and in how many sessions and days. From that window Thoth produces a report and proposes
rules. **A baseline proposes; a person enforces.** Nothing here switches an agent to enforce, and
nothing leaves "ready to review" without a person.

It is a count of what the agent did, not of what it intended. It is not a model, a score or a
detection rate.

## Availability

The baseline is off unless the operator of the deployment turned it on (see
[Turning it on](#turning-it-on)). Today it is configured through the Thoth configuration MCP server
and the API. Terraform, `thothctl` and the dashboard do not manage it yet; this page says when that
changes.

## The steps

| State | What it means | Who moves it |
| --- | --- | --- |
| `off` | Nothing is collected. The default for every agent. | |
| `learning` | A window is open and counters accumulate. No deviation is checked while it learns. | An org admin starts it |
| `ready_to_review` | The window has the minimum days (default 7), actions (50) and sessions (5). | Computed; a person can also freeze early and the report says which minimums were not met |
| `proposed` | The window is frozen into an immutable revision with a report and its `report_hash`. | An org admin proposes (freezes) |
| `accepted` | The revision is the reference for deviations. Deviation checks start in **observe**. | A signed-in org admin with a recent second factor (or, keyless, a fresh sign-in), who names the revision and the exact `report_hash` they reviewed |
| `declined` | Recorded with who and when. The counters expire and learning can restart. | The same kind of admin |
| `drift_review` | From `accepted`, a person starts a re-review from what the agent has done since. The accepted baseline stays the reference. | An org admin |

Accepting a baseline commits none of the proposed rules, and it does not change the agent's own mode.
Every change except the deviation settings is a signed-in person's. An admin API key (Terraform
and automation) can set the deviation settings only, including `enforce` and `deny`; that is audited with
the factor `api_key`. It cannot accept or decline, and it cannot start, stop or propose.

Accepting, declining and changing the deviation settings need a verified second factor. On a stack that
signs people in without a WorkOS API key ("keyless"), Thoth cannot verify one, so a **fresh
sign-in** by a signed-in org admin is accepted instead, when the sign-in step-up is on. **A fresh
sign-in is not MFA**: it only shows the person signed in recently, and the record says
`idp_fresh_signin`, not `mfa`. A stale sign-in is asked to sign in again. Every change's audit entry
and the baseline's state record the factor used (`accepted_factor`, `declined_factor`,
`deviation_set_factor`).

## What is stored

Counts of tool names, action classes and argument shapes (for example "the destination was an
allow-listed host", never the host), per day, with first and last seen and a capped set of
session fingerprints used only to count distinct sessions. **Not stored:** argument values, hashes
of arguments, prompts, output, file paths, commands, working directories, host names, URLs, e-mail
addresses, recipient domains or user ids. Tool names are reported by your agents; treat them as data,
not instructions.

With arguments hashed or redacted by [data handling](https://docs.atensecurity.com/docs/operations/data-handling), destination
and path features are *unobserved* unless the client sends findings; the report says how many
actions had each feature unobserved.

## The report

Deterministic: the same counters give the same report and the same `report_hash`. It lists

- **normal behaviour**: each tool and class combination with its calls, days seen and share of sessions;
- **new or rare**: seen in fewer than two sessions;
- **seen, not learned**, with the reason: actions a rule would have held or denied, that the
  outside-recipient guard flagged, or that carried a credential finding are never learned as normal;
- **which tools followed which**, for consequential actions;
- an **internal hold-out back-test**: the first 70% of the window's days against the rest. It is an
  internal measurement on this agent's own data, not a detection rate.

## Proposed rules

The proposals are the exact arguments for `preview_policy_rule`, a `thothctl` command and a
Terraform snippet. Reading them creates nothing. A rule applies only when you preview and commit it
like any rule, and an org admin approves it. A rule names tools, so it cannot cover a tool the agent
never used; only the deviation check, after acceptance, covers that.

## Deviations

After a person accepts a revision, an action outside it is a *deviation*: a new action, a new
destination for a known action, or a new order (a tool after a source it never followed). Only
consequential actions count; a new read-only tool is listed as new, not held.

| Setting | Values | Effect |
| --- | --- | --- |
| `deviation_mode` | `off`, `observe` (default after accepting), `enforce` | `observe` records what would have happened. `enforce` acts only when the agent itself is in enforce; an agent in observe still runs the action. |
| `deviation_action` | `hold` (default), `deny` | What an allowed deviation becomes under `enforce`: held for approval, or denied. It never lowers a decision. |

An org admin sets both. **Deviations recorded in observe count toward the Ready to enforce rate**
(the existing 2% check), so a noisy or immature baseline delays an agent's readiness. It can never
make an agent look more ready. Setting `deviation_mode` to `enforce` is its own change and never
switches the agent's mode.

If the baseline store cannot be read, the check does nothing and records that it was unavailable;
it never changes a rule's, the recipient guard's or a budget's decision.

## Over MCP

| Tool | What it does |
| --- | --- |
| `get_behavioural_baseline` | The state, the minimums and progress, the deviation settings and the report. Members see agents they own; admins see any. |
| `list_baseline_proposals` | The proposed rules and settings. Creates nothing. |
| `preview_baseline` | Preview one change: `start`, `restart`, `evaluate`, `propose`, `accept`, `decline`, `drift_review`, `cancel_drift_review`, `stop` or `set_deviation`. Accepting and declining need `revision` and `report_hash` from the report, and the person confirms in the browser with a recent second factor. |

Every change writes an audit entry (who, which agent, the states before and after, the revision,
the report hash and the factor) **before** it is applied; if the entry cannot be written, nothing
changes.

## Limits

- It learns what happened, not what was right. A habit already present in the window is learned
  as normal, including by an agent that was already misbehaving.
- Slow drift stays inside the baseline until a person re-reviews it.
- A new agent has no baseline until a window passes; ten days and a few people give wide uncertainty.
- Rare is not wrong and common is not safe: a legitimate once-a-quarter action looks like a deviation.
- Ordering is limited to one session's recent calls, and sources are tool-name patterns, not the
  data that was read.
- At most 500 behaviours per agent and 500 session fingerprints per behaviour; beyond that the report
  says it was truncated.
- Ready to enforce reads recorded decisions. On a deployment where decision capture is off, it
  does not see deviations.

## Turning it on

On a customer-hosted stack, set `thoth_behaviour_baseline_enabled = true` in the customer module (it
sets `BEHAVIOUR_BASELINE_ENABLED=true` on the enforcer). The default is off. Even when on, an agent
collects nothing until a person starts a window for it. With the flag off the baseline routes answer
that the baseline is not enabled for the deployment.
