---
title: "Protect agent runs with ABAC"
source: "https://docs.vertesiahq.com/security/agent-run-access"
markdown: "https://docs.vertesiahq.com/llms/security/agent-run-access.md"
---

# Protect agent runs with ABAC

Use the `agent_run` ABAC scope when different teams or applications may use the same project but should see or control
only their own class of agent and process runs. RBAC still decides whether a caller may use run APIs at all; ABAC
narrows that access to matching run records.

## Choose the role

| Role | Operations |
| --- | --- |
| `agent_runs:reader` | Read matching runs, streams, artifacts, child details, and process-run state. |
| `agent_runs:operator` | Read plus control matching runs. |

Control includes cancellation, termination, restart, fork, signals, messages, artifact writes, and process actions.
Queries are reads. Creating a run continues to use the caller's system permission; ABAC applies to later reads and
controls.

## Understand the access decision

Without an agent-run ABAC role, project-visible runs retain the normal project baseline and private runs remain
limited to their owner. Once a principal receives any agent-run ABAC role, the `agent_run` scope becomes restricted
for both read and control:

- the principal that started the run remains an owner and keeps access;
- a matching Reader rule grants read but not control;
- a matching Operator rule grants read and control;
- project visibility alone no longer grants access.

Administrative read permissions and workflow super-administration remain explicit bypasses. Aggregate run analytics
require unrestricted read access and return 403 for a token carrying an agent-run ABAC policy.

## Select run fields

Resource conditions evaluate the stored run record. Common fields are:

| Field | Example |
| --- | --- |
| `run_kind` | `agent` or `process` |
| `run_type` | The run execution type. |
| `interaction` | Interaction ID, name, or versioned reference. |
| `started_by` | Principal reference that created the run. |
| `visibility` | `project` or `private`. |
| `tags`, `categories` | Application or organizational labels. |
| `source_type` | Source classification for the run. |
| `properties.` | Custom metadata, such as `properties.department`. |

Prefer fields assigned by a trusted application or server workflow. A caller that can choose a field's value can
make a run match a rule based on that field, so do not treat untrusted custom metadata as the only security boundary.

## Create the rule in Studio

1. Open **Project Settings → Permissions** and select **New**.
2. Under **Who**, select a user, group, or API key, or create a **Principal Set**.
3. Under **Target Resource**, select **Resource Set**.
4. Set **Scope** to **Agent run**.
5. Select **Agent Run Reader** or **Agent Run Operator**.
6. Give the Resource Set a descriptive name and enter the run conditions.
7. Create the permission, refresh the test principal's token, and verify allowed and denied runs.

For department isolation, compare a trusted run property to the principal's own department:

```json
{
    "properties.department": { "$eq": "$principal.properties.department" }
}
```

Add `run_kind` when the policy should cover only agent or only process runs:

```json
{
    "properties.department": { "$eq": "$principal.properties.department" },
    "run_kind": { "$eq": "agent" }
}
```

Conditions inside one Resource Set use AND semantics. Separate rules are additive OR branches.

## Test with Studio Assistant

Ask Studio Assistant to test the proposed rule before saving it. Supply the scope, operation, role, principal context,
conditions, and representative run-shaped objects. For example:

> Test `agent_runs:operator` for `control` in the `agent_run` scope. The principal's department is Finance. Compare
> `properties.department` to `$principal.properties.department` against one Finance agent run and one Legal agent
> run.

The result is rule-local. It does not include run ownership, other rules, project visibility, or administrative
bypasses. After saving, obtain a fresh token and test the real list, individual read, and control endpoints.

## Roll out safely

1. Use a non-production principal and representative run records.
2. Create the intended Reader and Operator grants first.
3. Add a deliberately non-matching Reader rule for the target Principal Set if you need to activate restriction
   before any real rule matches.
4. Refresh the token and verify list/search omission, individual 404 responses, and control behavior.
5. Test both agent and process runs, including private runs and owner access.
6. Expand the Principal Set only after the matrix behaves as intended.

An empty Resource Set is a wildcard grant. Use it only when every run in the project should be available through that
role.