# Autonomy and guardrails

> How the agent acts without waiting for you: brokered actions, presets, classes and gates, budgets, checks, undo window, breakers, questions, and the freeze switch.

Source: https://docs.ventgris.com/workspace/autonomy

No task in Ventgris waits for a human. A session, a job or a channel conversation runs to its end on its own, including the steps that send, publish or spend. What makes that safe is that the agent never acts on the outside world directly: it asks the **broker**, part of the workspace's control plane, to run a declared **brokered action**, and the broker applies guardrails written as code. You watch, cancel, and stop everything if needed. The **Autonomy** screen shows these rules and holds the switch that freezes everything.

![Autonomy screen with the freeze switch, the preset, the gates by class, the actions and the budgets](https://docs.ventgris.com/img/autonomy.png)

## Why the agent cannot bypass the rules

| Layer | What it guarantees | Relies on the model |
|---|---|---|
| Absence | A key that sends, publishes or spends is never in the agent's environment. It stays in the vault | no |
| Brokered action | The agent fills a typed input for a declared action. It cannot choose the URL, the headers or the account | no |
| Guardrails | Schema, checks, allowlists, budgets, deduplication, undo window, breakers, applied inside the control plane | no |
| Review after the fact | The [Activity](https://docs.ventgris.com/workspace/activity.md) feed and the audit journal | no |
| Instructions | The agent profile says what is expected | yes |

Only the last line relies on the model behaving. It improves quality; it is not a safety mechanism.

## Classes and gates

Each brokered action belongs to one **class**, which sets its default **gate**.

| Class | Meaning |
|---|---|
| `internal` | Stays inside our own tools |
| `reversible` | Can be undone before anyone sees it |
| `broadcast` | Reaches people outside, cannot be taken back |
| `spend` | Costs money |
| `destructive` | Removes or rewrites something |

| Gate | Behaviour |
|---|---|
| **auto** | Runs at once |
| **notify** | Runs after an undo window (a delay). Shown in the feed with a countdown and **Cancel** until it leaves |
| **approve** | Waits for a person to approve. Always has a timeout, after which it is rejected (or runs, if the rules say so). A task never hangs on it |

An action refused by a guardrail is **blocked**: the agent gets the reason at once and carries on. A blocked action is not parked for approval.

## Presets

The preset sets the gate of each class:

| Preset | Effect |
|---|---|
| `autonomous` | No class waits for a human. `broadcast` is **notify** with the undo window; the others are **auto** |
| `supervised` | `broadcast` and `destructive` are **approve**, and `spend` above a threshold is **approve** |
| `custom` | Each action declares its own gate. An action with none is refused |

A gate written for one action wins over its class. An agent or a channel can have its own preset; an override to `supervised` can only make things stricter. The screen lists them under **Overrides** ("agent intern: supervised").

On a Ventgris workspace the rules start with the preset `autonomous`, and messages to third parties on Discord, Telegram and WhatsApp behind an approval, because the text checks that would let them leave alone are not available yet.

> [!NOTE]
> The preset, the gates and the action definitions are read only on the screen: "The preset and the gates are read from /etc/ventgris/autonomy.toml, owned by root." They are outside the agent's reach and are not edited from the interface. Budgets and breakers are.

### Destructive actions

A `destructive` action runs only after a snapshot. Snapshots are not available on workspaces yet, so a destructive action is always blocked with "no snapshot is possible, a destructive action does not run without one".

## Read the Autonomy screen

From top to bottom:

1. **Kill switch**: the freeze button and the current state.
2. If the rules failed to load: a red banner **The policy is not loaded**, and a table **Refused when the rules were loaded** with the file, the action and why.
3. **Preset**: the preset and its defaults, with **Reload the rules**.
4. **Gates by class**: one row per class with its meaning and gate.
5. **Actions**: every declared action, its gate, guardrails and state.
6. **Budgets**: every budget and its use.
7. **Circuit breakers**: the breakers that tripped.

The screen updates live. **Refresh** reloads it.

### Preset and defaults

| Line | Default |
|---|---|
| **Undo window of a broadcast** | 10 min |
| **After untrusted content** | 30 min |
| **Approval timeout** | 24 h |
| **At the timeout** | **rejected** (or **runs**) |
| **Spend needing approval above** | only under `supervised` |
| **Internal actions per hour** | 120, for an internal action with no count budget |
| **Breaker** | "3 failures, 1 h then doubling up to 24 h" |

**Reload the rules** reads the rule files again ("Rules reloaded: 12 action(s)"). It needs your second factor. If a file does not load, every action is refused until it is fixed: the broker fails closed.

### Actions

| Column | Content |
|---|---|
| **Action** | Its title and its name, for example **Make an artifact public**, `art.publish_public` |
| **Class** | |
| **Gate** | The gate, its delay ("after 10 min", "30 min after untrusted content"), its timeout ("24 h, then rejected"), where it is set ("set in autonomy.toml", "set in the action file"), and "approval needs the second code" |
| **Guardrails** | The guardrails of the action and its budgets with their use |
| **State** | **open**, **paused** (a breaker is open), **trial run** (half open), or **refused** with the reason |

**Pause** on an action trips its breaker after a confirmation: "Its runs are refused for a day, or until someone resets its breaker."

## Guardrails

| Guardrail | Shown as | What it does |
|---|---|---|
| Schema | **schema** | Refuses an input that does not match the action's JSON schema |
| Checks | **checks: no_secret, slopcheck** | Scripts run on the input. All must pass. A check that cannot run refuses |
| No secret | (always) | An input holding a value of the vault is refused, and the action's breaker trips |
| Allowlist | **allowlist: input.account ∈ a, b** | Targets must be in a list |
| Deduplication | **dedupe 24 h** | The same input twice inside the window is refused: "the same input already went through as act_..." |
| Budget | under the guardrails | Counts runs, recipients or euros per period |
| Hosts | **hosts: api.example.com** | The only hosts the action may call |
| Secret | **secret NAME** | The vault secret the broker uses for it. The agent never sees it |
| Estimate | **estimate 0.40 €** | The declared cost of one run, for spend budgets |

## Budgets

A budget caps an action, a class, an agent or everything over a period. A `broadcast` or `spend` action with no budget is refused: there is no unlimited default ("No budget yet. Broadcast and spend actions are refused without one.").

Each budget shows its scope, what it counts and per what period, a bar ("4 of 20"), **above 80 %** in orange and **cap reached** in red, and when it resets. At 100 % the action is blocked until the period rolls over. A budget split by a field (**one counter per input.account**) shows one bar per value.

| Source tag | Meaning |
|---|---|
| **action file** | Declared with the action |
| **set here** | Added or changed on this screen. "the action file says 20" shows the original |

### Add a budget

1. Click **Add a budget**.
2. **Scope**: **Everything**, **A class**, **An action** or **An agent**, then the class, the action or the agent name.
3. **Counts**: **runs**, **recipients** or **euros**.
4. **Per**: **hour**, **day**, **week** or **month**.
5. **Limit**: a number, zero or more.
6. **Split by (optional, e.g. input.account)**: one counter per value of that input field.
7. Click **Add** and enter your second factor.

Each budget row has **History** (the use of past periods), **Change the limit**, and, for a budget set here, **Remove** or **Back to the file**. All changes need your second factor.

Spend is counted from the cost the provider reports when it gives one, from the declared estimate otherwise. Model usage of sessions is not part of these budgets.

## Untrusted content

A turn that read the web, a mailbox or a third-party tool is marked tainted (see [Sessions](https://docs.ventgris.com/workspace/sessions.md#untrusted-content-and-taint)). Its brokered actions keep their abilities, with differences:

- a `broadcast` action waits the longer undo window (30 min by default), even under a gate that would run it at once,
- the feed tags it **after untrusted content**,
- **Send now** on it needs your second factor.

All other guardrails apply to every turn, tainted or not.

## Circuit breakers

A breaker pauses an action, a class or an agent that misbehaves. It trips when:

| Trigger | Example |
|---|---|
| 3 failures in a row | The provider answers 401: the key was revoked |
| More runs in an hour than 3 times the usual hour of the last 7 days | A loop posts every minute |
| More than half of the last 10 runs failed their checks | The agent keeps producing text a check blocks |
| A vault secret was found in an input | A leak attempt |
| A person clicked **Pause** | |

Once tripped (**open**), the action is refused for a cool-down of 1 hour. Then one call goes through as a trial (**half open**). If it fails, the cool-down doubles, up to 24 hours. Every trip writes an audit line.

The **Circuit breakers** table shows each breaker that tripped: **On** (for example `action:discord.post`), **State** (**closed**, **open**, **half open**), **Reason**, **Trips in a row**, **Tripped**, and **Next trial**. **Reset** closes it at once after a confirmation and your second factor. A breaker never pauses a job.

## The undo window

A **notify** action is scheduled, not sent. In the Activity feed and above the composer of its session, it shows **Delayed** with a countdown ("leaves in 8:42"), and two buttons:

| Button | Effect | Who |
|---|---|---|
| **Cancel** | "Cancel “title”? It will not leave." | Admins, editors and members |
| **Send now** | Sends without waiting for the end of the window. Needs your second factor after untrusted content | Admins and editors |

If its state changed meanwhile, the screen says "Too late: its state changed."

## Approvals

An **approve** action shows **Waits for approval** with its timeout ("rejected in 23 h 10 if nobody answers", or "runs in ... if nobody objects"):

- **Approve**: "Approved. It leaves now." Some actions need your second factor to approve ("approval needs the second code").
- **Reject**: asks for an optional word for the agent, then rejects.

Admins and editors can decide. Nothing can be approved while everything is frozen: "Everything is frozen: thaw first."

## Questions with a default

When the agent needs a decision it would have asked you for, it asks a question that carries its own answer:

```bash
vg ask "Two titles fit. Use A (shorter) or B (names the guest)?" --choices A,B --default B --timeout 30m
```

| Rule | Value |
|---|---|
| A default is required | A question without one is refused: the agent must say what it would do |
| Choices | Up to 12. The default must be one of them. Without choices, you answer in free text (200 characters) |
| Timeout | 30 min by default, 24 h at most. In a scheduled job, 0: the default applies at once |

The question appears in the Activity feed with its choices, the default marked **default**, and "“B” applies in 12:30". Click a choice (or type and click **Answer**) to send it to the task. At the timeout the default applies and the feed says "Answered by default". Members can answer too.

An answer given after the default applied is kept: "Answered afterwards: “A”. The task had gone on with the default." The task does not change, but the answer is recorded for next time.

## Freeze everything

The **Kill switch** card at the top of the screen stops everything that leaves the workspace at once.

1. Click **Freeze everything**.
2. Confirm "Freeze everything now? No action leaves until someone thaws."

While frozen:

- every brokered action is refused: "frozen: the kill switch is on, nothing leaves",
- delayed actions keep their place and do not leave. Their countdowns stop ("stopped at 4:10"),
- no scheduled job and no background task starts,
- nothing is killed: running sessions and tasks continue.

The card turns red: **Everything is frozen**, since when, by whom and from where (**from the interface**, **from a channel**), and what is held back ("2 delayed action(s), 1 waiting for approval, 0 open question(s)").

No second factor is asked to freeze: it is the emergency stop. Admins and editors can freeze. An admin of a channel can also send `/freeze` in a channel conversation.

To resume, click **Thaw** and confirm. Thawing needs your second factor and an admin. Delayed actions resume the rest of their undo window. `/thaw` works from a channel too.

> [!WARNING]
> Freeze is the answer to "something is wrong and I do not know what yet". It does not undo what already left. Look at the [Activity](https://docs.ventgris.com/workspace/activity.md) feed for what ran.

## Who can do what

| Action | Admin | Editor | Member | Viewer |
|---|---|---|---|---|
| Read the screen and the feed | yes | yes | yes | yes |
| Freeze | yes | yes | no | no |
| Thaw, reload the rules, add or change budgets, reset breakers, pause an action | yes | no | no | no |
| Approve, reject, send now | yes | yes | no | no |
| Cancel a delayed action, answer a question | yes | yes | yes | no |

## Related

- [Activity](https://docs.ventgris.com/workspace/activity.md)
- [Brokered actions for agents](https://docs.ventgris.com/agents/brokered-actions.md)
- [Secrets](https://docs.ventgris.com/workspace/secrets.md)
- [Sessions](https://docs.ventgris.com/workspace/sessions.md)
- [Security overview](https://docs.ventgris.com/security/overview.md)
