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

# Smart Rules

> Mask and block sensitive data in your AI agents' tool calls automatically.

**Smart rules** keep sensitive information away from your AI agents, using a plain-language description of the information you want to restrict. StackOne then masks or blocks that information on every connector, without you defining an explicit path for every tool.

## When to use smart rules

Use a smart rule when the same kind of data sits in differently named fields across your connectors, so a field path would miss some of them:

> [accordion] Salaries stay hidden on every HR connector
>
> Each HR provider names its pay fields differently, so masking them by path means one pattern per connector, and a new connector is uncovered until someone adds its pattern.
>
> A policy with **Resource** set to **None** and one **Mask fields by label** statement naming the built-in `compensation` label masks pay fields on every connector, including ones added later. Keep **Unlabelled** on **deny** to mask fields the classifier is unsure of too.

> [accordion] Agents can't change bank details
>
> An agent that updates employee records shouldn't be able to change where people get paid, whichever system holds the details.
>
> Create a `bank_details` [project label](#create-a-label) describing bank account numbers, sort codes and IBANs. A **Refuse writes by label** statement naming it refuses any call that writes those details, and the agent's other updates go through.

## Labels

Each description is saved as a **label**. StackOne provides built-in labels, and you can [create your own](#create-a-label). To use one, add either of these [Tool Policies](https://docs.stackone.com/secure/policies) statements when you [build a policy](https://docs.stackone.com/secure/policies#build-a-policy-manually):

* **Mask fields by label** masks response fields that hold the labelled data.
* **Refuse writes by label** refuses calls that write it.

A model decides which fields hold the data from each field's name and path, the type of value it holds, the field names beside it, and the action that returned or writes it. Field values are never sent for classification. When the model can't decide, the statement's [**Unlabelled**](#unclassified-fields) setting does.

Open [**Project Settings > Policies**](https://app.stackone.com/settings/policies) and select the **Labels** tab to view the labels available in your project:

* **Built-in labels**: Defined by StackOne (for example `compensation`). StackOne measures classification accuracy for built-in labels. These labels cannot be edited or deleted.
* **Project labels**: Defined in your project. StackOne has not measured their classification accuracy, so they carry an **Unmeasured** tag. Run policies that name unmeasured labels in **Monitored** first to verify decisions before enforcing them.

### Create a label

**1. Open the Labels tab**

Select the project, open [**Project Settings > Policies**](https://app.stackone.com/settings/policies), and select the **Labels** tab.

**2. Enter label details**

Click **Create label**.

Set the following:

* **Name**: the name rules use for the label, for example `bank_details`. The name cannot be changed after the label is created.
* **Description**: the data a field must hold to match the label, for example `Bank account numbers, sort codes and IBANs`. Describe the data rather than field names.

**3. Save the label**

Click **Create**.

You can edit a project label's description at any time from its row on the **Labels** tab. A label can only be deleted once no saved policy in the project names it.

## Unclassified fields

A field is unclassified when the classifier is unsure whether it matches.

A smart rule's **Unlabelled** setting decides what happens to unclassified fields:

* **deny**: treats an unclassified field as if it matched, so it's masked in a response or the write is refused. This is the default.
* **allow**: lets unclassified fields through. Fields that match a label are still masked or refused.

**1. Open Policies**

Select the project and open [**Project Settings > Policies**](https://app.stackone.com/settings/policies).

**2. Open the policy**

Click the policy in the table to open its side panel.

**3. Set Unlabelled**

1. On the smart rule's statement, set **Unlabelled** to **deny** or **allow**.
2. Click **Save changes**.

> [!WARNING]
>
> If the classifier can't be reached, every field is unclassified. With **allow**, the rule **masks and refuses nothing until the classifier recovers**, so keep **deny** for fields that must stay protected. With **deny**, every field except record IDs and paging cursors is masked or refused until then.

In Cedar, the setting is the `@unlabelled("allow")` annotation above the statement. Without it, the statement uses `deny`.

## Pause smart rules in a project

Turning **Smart Rules** off pauses every smart rule in the project's policies. The policies' other statements keep applying.

**1. Open AI Settings**

Select the project and open [**Project Settings > AI Settings**](https://app.stackone.com/settings/ai-settings).

**2. Turn Smart Rules off or on**

1. Under **Policies**, turn **Smart Rules** off to pause smart rules, or on to resume them.
2. Click **Confirm**.

> [!NOTE]
>
> Smart rules keep running when AI features are turned off with the **Status** switch in AI Settings. Use **Smart Rules** to pause them.

## Related

> [card] [Tool Policies](https://docs.stackone.com/secure/policies)
>
> Build the policies that hold your smart rules.

> [card] [PII Redaction](https://docs.stackone.com/secure/pii-redaction.md)
>
> Redact personal data from responses by category instead of by label.


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