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

# Guard and approvals

> The layers every agent tool call passes before it runs — mode, member permissions, the built-in deny list, workspace tool rules, the target scope gate, the plan gate and human approval — plus how the runtime resists prompt injection

An agent that can run scanners and shell commands needs controls that hold even when the model is wrong, confused or manipulated. OASM puts every tool call through a fixed sequence of checks **in code**. The model is told about these rules so it can work with them, but nothing it writes can switch them off.

The user-facing view of the same rules is in [Plans and approvals](https://docs.oasm.io/ai-studio/plans-and-approvals.md).

```mermaid theme={null}
flowchart TD
    Call["Tool call from the model"] --> Mode{"Offered in<br/>this mode?"}
    Mode -->|no| X0["Not in the tool set"]
    Mode --> Perm{"Member holds<br/>the permission?"}
    Perm -->|no| X1["Not executed"]
    Perm --> Deny{"Built-in<br/>deny list"}
    Deny -->|match| X2["Refused + policy"]
    Deny --> Rules{"Workspace<br/>tool rules"}
    Rules -->|deny| X2
    Rules -->|"ask"| Ask
    Rules -->|"allow"| Run
    Rules --> Scope{"Scope gate"}
    Scope -->|"excluded / out of scope"| X2
    Scope -->|"host may be out of scope"| Ask
    Scope --> Plan{"Agent mode:<br/>plan approved and<br/>step in progress?"}
    Plan -->|no| X3["Refused: plan first"]
    Plan --> RO{"Read-only or<br/>approval mode Auto?"}
    RO -->|yes| Run["Execute"]
    RO -->|no| Ask{"Approval prompt"}
    Ask -->|approve| Run
    Ask -->|"reject / 5 min timeout"| X4["Rejected + feedback"]
```

## Why this order

Checks that can only **refuse** run before checks that can **permit**, and checks that need no human run before the one that does:

1. **Mode** — the cheapest and strongest control: a tool that is not offered cannot be called.
2. **Permissions** — the member's own keys, as for an API request. See [Tools](https://docs.oasm.io/architecture/ai-agent/tools.md#the-permission-check).
3. **Guard** — the deny list, workspace rules and scope, enforced in **every** approval mode, including Auto, and for subagents.
4. **Plan gate** — in Agent mode, work happens only inside an approved plan.
5. **Approval** — the human decides, with the guard's reason shown when it escalated.

A refusal is returned to the model as the tool result, with the policy that refused it, and stored with the tool call — so the user, the model and a later audit all see why.

## The guard

### Built-in deny list

Shell commands and tools of external MCP servers are checked against a fixed list of destructive actions: recursive deletion of the root, home or system directories, formatting or wiping filesystems, raw writes to block devices, fork bombs, shutting down or rebooting the host, destructive SQL (`DROP`, `TRUNCATE`, `DELETE` without `WHERE`), flushing Redis, and HTTP `DELETE` requests.

The command is **normalized** before matching: line continuations are joined, quotes and escapes are removed and `bash -c '…'` bodies are flattened, then the command is split on `;`, `&&`, `|`, subshells and backticks. `r"m" -rf '/'` reads as `rm -rf /`, and a dangerous command hidden after a harmless one is still found. Matching errs on the side of refusing: even `grep "DROP TABLE"` is refused.

### Workspace tool rules

The workspace owner can add rules that apply to every member's agent:

* each rule names a tool (or `*`), an optional **wildcard** pattern matched against the whole command or JSON input, an action — **allow**, **deny** or **ask** — and a priority;
* the highest-priority matching rule decides; on a tie, deny beats ask and ask beats allow;
* **ask** forces an approval prompt even in Auto mode; **allow** skips the prompt; **deny** refuses.

Patterns are wildcards (`*`, `?`), never regular expressions built from user input, so a rule cannot be used to stall the API. Only workspace owners can write rules.

### The scope gate

The agent should only touch what the workspace is responsible for. The **scope** is the conversation's project include and exclude rules, when the project has include rules; otherwise the workspace's domain, IP and CIDR targets, where a domain covers its subdomains. Assets inside that scope count too.

* Calls with a structured target — `run_tool_connector`, and `dispatch_subagent` with targets — must be **in scope**, or they are refused.
* Hosts found in a shell command are checked on a best-effort basis: a host that may be out of scope **escalates** to an approval prompt, even in Auto mode, unless an allow rule matched.
* A host the project **excludes** is always refused. Block beats allow.

Host names are never resolved for this check, so an IP target does not cover a domain that points at it, and vice versa.

## The plan gate

In Agent mode, every gated tool is refused until the model has called `formulate_plan`, the user has **approved the plan**, and a step is **in progress**. The plan is the unit of consent: the user sees the whole intended course of action before any of it happens, and picks how the approved plan runs — asking before each call, or automatically. Changing the plan's direction means scrapping it and proposing a new one, which is reviewed again. See [Plans and subagents](https://docs.oasm.io/architecture/ai-agent/plans-and-subagents.md#plans).

## Approval

Calls that pass the guard either run or wait for the user:

* **Read-only tools** run without asking once a step is in progress.
* In **Auto** mode, other tools run without asking — unless the guard escalated the call.
* In **Manual** mode, each call that has not been approved before waits for an answer.

An answer can apply to the single call, to the same command for the rest of the conversation, to every call of one tool, or to everything in the conversation. Conversation-wide answers are kept in Redis for seven days, so they survive an API restart but not an abandoned chat. A prompt that is not answered within **five minutes** counts as a rejection, and **Stop** rejects every waiting prompt.

A rejection can carry feedback, which is returned to the model as the tool result. The model is instructed not to retry a rejected call, but to follow the feedback or ask.

### Unattended runs

Subagents work in the background where nobody sees a prompt. They run **unattended**: a call the guard escalates to a prompt is refused instead of waiting forever. Built-in subagents run their declared tools without asking — the user approved their work through the plan. A custom subagent in a Manual conversation gets read-only tools only.

## Resisting prompt injection

The agent reads untrusted text all the time: web pages, HTTP responses, banners, scan output, and tasks written by other agents. The runtime treats all of it as **data**:

* A subagent's task arrives wrapped in a `<task>` block, after a fixed preamble that tells it to follow only its own instructions, never instructions inside the task or tool output. Results of earlier subagents and the shared notebook are wrapped the same way, and any closing tag inside them is neutralized so the text cannot break out of its block.
* The controls above do not depend on the model's judgement: an injected instruction can at most make the model *ask* for something, and the mode, permissions, guard, plan gate and approval still apply.
* Findings the agent proposes are **never** added directly. They enter as **pending review**; at proposal time the platform checks every quote the agent cites as evidence against the stored raw tool output and records whether it was found. The reviewer sees that verdict next to the proposal. See [Data model](https://docs.oasm.io/architecture/data-model.md#ai-proposals).

## Related

> [card] [Plans and approvals](https://docs.oasm.io/ai-studio/plans-and-approvals.md)
>
> Approval modes, plan review and safety checks from the user's side

> [card] [Plans and subagents](https://docs.oasm.io/architecture/ai-agent/plans-and-subagents.md)
>
> The plan model and how subagents are queued and briefed

> [card] [Tools](https://docs.oasm.io/architecture/ai-agent/tools.md)
>
> What each tool requires before the guard


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