> ## Documentation Index
> Fetch the complete documentation index at: https://docs.budecosystem.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Governance policies

> How governance works, how to write a policy, and how to attach it to an agent in shadow mode first.

Governance policies decide, at each step of a run, whether an agent may continue. Risky steps can wait for a person. Every run can be watched, steered and stopped from the agent's **Runs** tab.

![Guardrails → Governance Policy lists the policies agents can be held to.](https://mintcdn.com/budecosystem-b7b14df4/tm7AvlRzpE_EcnqL/images/product-guide/governance.jpg?fit=max\&auto=format\&n=tm7AvlRzpE_EcnqL\&q=85\&s=eb1fb581b96d64d6cf3a9fa90001e2af)

Guardrails → Governance Policy lists the policies agents can be held to.

## How governance works

A **policy** is a set of **rules**. A policy is defined once, deployed to a project, and then **attached** to individual agents. Each attachment (a *binding*) has its own mode, scope and approvers, so the same policy can enforce on one agent and only observe on another.

### When rules run

Rules run at fixed points in an agent's run. Each rule names the points it runs at under **Run when**:

| Option | Agent page shows | When it runs |
| - | - | - |
| **Before the request** | Model input | Before each request to the model. |
| **Before a tool runs** | Tool call | Before a tool is called. Escalating here holds the call until a person decides. |
| **After a tool runs** | Tool result | After a tool returns, before the model sees the result. |
| **After the reply** | Model output | After each model reply, before it is used or shown. |
| **Before the run starts** | Run start | Once per run, before any model call: location, budget or trigger-source gates. Offered where your installation enables it. |
| **After the run** | Run end | Once per run, after the agent finishes. Offered where your installation enables it. |

### What a rule can decide

| Then | Effect |
| - | - |
| **Allow** | Lets the action proceed. Use it as an explicit exemption. |
| **Redact** | Masks the matched value and lets the rest continue. |
| **Notify** | Proceeds unchanged and flags a person to review it afterwards. |
| **Escalate** | Pauses and asks a person to approve before continuing. |
| **Deny** | Blocks the action and tells the caller why, using the rule's **Guidance**. |

### How verdicts combine

* **Within one policy**, the policy's **When rules conflict** setting picks the winner among the rules that match.
* **Across policies** on the same agent, each policy gives its own verdict for the moment and the strictest one wins, in this order: **Deny, then Escalate, then Redact, then Notify, then Allow**. Redact and Notify do not compete: they are duties that apply only if the action goes ahead. If any policy denies or escalates, redactions and notifications from the others are dropped.
* If several policies escalate at once, they are merged into one approval request. When tied, the policy attached first sets the wording shown.
* A standing **Allow Always** grant can turn an Escalate into an Allow for the same action in the same session. It never overrides a Deny, a Redact or a Notify.

## Create a governance policy

**Who:** someone with permission to manage guardrails

**Where:** Guardrails → Governance Policy → + Add Policy

1. Fill in the policy fields below.
2. Under **Rules**, click **Add checks** to add a rule that uses Bud Guardrails and scanners, or **Add patterns** to add a rule that matches text patterns. Rules are collapsible; each has an on/off switch and a delete icon.
3. Fill in each rule (table below).
4. Click **Save Policy**.
5. Open the policy from the list. Where it is **active**, a **Deploy** button appears; click it and choose the project. Agents in that project can then attach it. **Edit** and **Delete** are in the policy's **⋯** menu.

### Policy fields

| Field | What to enter | Rules and defaults |
| - | - | - |
| **Policy Name** | For example `production-safety`. | Required. |
| **Description** | What the policy does and when it applies. | Optional. |
| **When rules conflict** | **Deny / Escalate wins**: if any matching rule denies, block; if any escalates, ask a person; otherwise allow. **Highest priority wins**: rules run in priority order and the first match decides. **Allow wins**: if any matching rule allows, it proceeds (a permissive default with explicit exemptions). **Most specific wins**: the most specific matching rule decides; an agent-scoped rule beats a global one. | Required. Applies within this policy only. |

### Rule fields

| Field | What to enter | Rules and defaults |
| - | - | - |
| **Rule Name** | For example `block-destructive-writes`. | Shown on the rule's header. An empty name is saved as `unnamed-rule`. |
| **Run when** | Tick one or more of the points listed above. | Required. If none is ticked, the rule runs **Before the request**. |
| **Checks** | Click **Add a check** and pick Bud Guardrails and scanners. Each shows its **Sensitivity**: **Lenient**, **Balanced**, **Strict** or **Max**. | Required. New checks start at Balanced. A pattern rule has a **Patterns** list instead: type a pattern and press Enter. It must have at least one. |
| **Then** | Allow, Redact, Notify, Escalate or Deny. | Required. For Escalate, who approves is chosen when the policy is attached to an agent. |
| **Guidance** | What the agent should say when the rule fires. | Optional. |
| **Only when** | Click **Add a filter**: a property such as `bud.user_country`, an operator (*is*, *is not*, *>*, *\<*, *contains*) and a value such as `prod`. | Optional. With no filters, the rule applies whenever its checks match. A filter with an empty property or value is dropped on save. The built-in `bud.*` names are listed in [Building an agent](https://docs.budecosystem.com/prompts-agents/building-an-agent.md). |
| **Priority** | A whole number, with minus and plus buttons. | 0 or more. Higher-priority rules are evaluated first. |

> [!TIP]
>
> A new policy cannot be deployed while it is a draft. A draft policy that is already attached to an agent shows "Draft: not running until it's activated in Guardrails". A policy deleted in Guardrails stops running and shows a **Detach** link on the agent.

## Attach a policy to an agent, and try it in shadow mode first

**Who:** Model manage permission. The agent must be saved first.

**Where:** Agent builder → Governance → Add policy

1. Click **Add policy**, search for the policy and click **Attach**. Only policies deployed to this agent's project are listed. If the list is empty, deploy a policy in Guardrails first.
2. The new attachment is selected. Set its **Mode** to **Shadow**. It records what it would have done and never blocks.
3. Set **Applies to**, add any **When** conditions, and set the escalation approvers if the policy escalates (table below).
4. After you have watched real traffic, switch the mode to **Active** to enforce.

Changes save as you make them. The panel shows *Saving…*, then the number of unsaved rows if any are held back; if you only have view permission it reads *View only*. If a change makes enforcement weaker (Shadow or Off, fewer approvals, **Allow always** on), the panel offers **Undo**.

| Setting | What it does | Rules and defaults |
| - | - | - |
| **Mode** | **Active**: enforces its verdicts. **Shadow**: records what it would do; never blocks. **Off**: not evaluated for this agent. | Defaults to Active. Shadow results appear in the audit trail as "would have" decisions. |
| **Runs at** | The stages the policy's rules run at. | Read-only: set by the policy. |
| **Applies to** | **End users**, **A2A** (calls from other agents) and **Triggers** (event-started runs). | All three by default. At least one must stay selected. |
| **When** | Conditions on the run, such as caller country, channel, tokens so far or cost so far. | Optional. When there is more than one, all must match. Run totals (`bud.tokens_so_far`, `bud.cost_so_far`) are re-checked before every step; the other values are fixed at run start. |
| **Escalation → Routes to** | Project members who may approve, chosen with **+ Add** (search by name or email), and **Invoker**, the caller approving inline through the API. | Needs at least one approver: with no member added, Invoker is on and locked. On a voice agent, **Approve by the caller · 30 s** is also offered. |
| **Escalation → Approvals** | How many approvals are needed (minus and plus). | 1 to 5. Cannot go below the policy's own minimum, shown as a lock and "min N". A warning shows if more approvals are needed than there are approvers. |
| **Escalation → Allow always** | Lets an approver grant a standing approval for the rest of the session. | On by default. Locked off if the policy forbids it. Not offered when the policy never escalates ("Never escalates"). |
| **Detach** | Removes the policy from this agent after you confirm. | The policy itself stays in Guardrails. |

There is no switch that turns off all governance on an installation. To stop a policy affecting one agent, set its mode to Off or detach it. Governance policies on an agent are enforced from the moment they are Active; there is no publish step that checks them first.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.