# Keep subagents on task

Give each subagent a purpose with tags, let Provenance compare every action with them, ask the person when an action doesn't fit, and let people deny with "Not what I asked for".

Use this when your agents hand grants to subagents and you want to catch one that drifts, such as a quote-finding subagent that starts buying. Limits keep a subagent inside the person's scope; a purpose says what it's for. Provenance compares each action with the purpose and asks the person when it doesn't fit.

Neither check denies anything on its own, and a model's answer can only make Provenance ask, never allow something a rule denies.

**Before you begin:** delegate with a purpose (see [delegate to subagents](https://provenanceauth.com/docs/mandate/guides/give-subagents-their-own-limits.md)).

## 1. Tag the purpose

`purpose_tags` (up to 10) name the action types or counterparties a subagent's task is about, each from the parent grant's lists:

**curl**

```bash
export PROVENANCE_API=https://sandbox-api.provenanceauth.com
export PROVENANCE_KEY=prv_test_acct_P9xN2vQ7bT4mW8sYd3cFjLh6gAe1kR5

curl -s $PROVENANCE_API/v1/mandate/grants \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "device_id": "dev_00000000000000000000000000000001", "purpose": "Restock printer paper for the office",
        "constraints": { "max_amount": 80, "allowed_action_types": ["quote", "purchase"],
                         "allowed_counterparties": ["paper.example", "ink.example"], "expires_at": "2027-12-31T23:59:59Z" } }' | tee parent.json
export PARENT_ID=$(jq -r .id parent.json)

curl -s $PROVENANCE_API/v1/mandate/grants/$PARENT_ID/delegate \
  -H "Authorization: Bearer $PROVENANCE_KEY" -H "Content-Type: application/json" \
  -d '{ "agent_session_id": "sess_paperfinder_3", "purpose": "Find A4 paper prices", "purpose_tags": ["quote", "paper.example"] }'
```

```json
{
  "object": "grant",
  "depth": 1,
  "purpose": "Find A4 paper prices"
}
```

## 2. Know what the pattern check says

Every verify under a child grant compares the action's `action_type` and `counterparty` with the tags of the subagent and every level above it:

| `purpose.fit` | When |
| --- | --- |
| `inside` | The action type or the counterparty is one of the tags. |
| `outside` | Neither is. |
| `untagged` | No level has tags, or the action names neither. |

The pattern check always runs and costs nothing.

## 3. Let the person decide what doesn't fit

For accounts created from October 31, 2026, a default rule asks the person when `purpose.fit` is `outside`. Verify returns `approval_pending` with `step_up_reason: "purpose_outside"`, and the approval says why above the request: "This doesn't look like part of 'Find A4 paper prices'." Once the person approves, the action goes through.

Turn the rule on or off in **Settings → Agents → Agent teams**, or with [`PUT /v1/mandate/settings/purpose_check`](https://provenanceauth.com/docs/api/grants.md#put-v1-mandate-settings-purpose-check) (an admin key or an owner or admin session). Accounts created earlier start with it off.

Your policy can use the facts directly, to deny instead of asking, or to ask only above an amount:

```json
{
  "rules": [
    {
      "id": "deny-off-purpose-purchases",
      "when": [
        { "fact": "purpose.fit", "op": "eq", "value": "outside" },
        { "fact": "action_type", "op": "eq", "value": "purchase" }
      ],
      "require": { "deny": true },
      "reason": "outside_purpose"
    }
  ]
}
```

## 4. Add the AI check

With the AI check on, verify also asks a model whether the action fits. It sends the chain's purposes, the action type, counterparty, amount and the agent's stated reason (`display_summary`), and nothing else: no subjects, cart pictures or payloads. The model answers with one of the values below and one sentence, which the approval shows.

| `purpose.check` | What happens |
| --- | --- |
| `consistent`, `unclear` | Nothing extra. Your policy can still read it. |
| `inconsistent` | The default rule asks the person. |
| `unavailable` | The check is off, the server has no endpoint, or it didn't answer in time (800 ms). Never a guess. |

A model can be argued with, so treat its answer as a reason to ask, never as proof. It never allows what a rule denies.

## 5. Let people say "Not what I asked for"

Every approval surface offers the deny reason `off_task` ("Not what I asked for"). Verify then returns `approval_denied` with `deny_reason: "off_task"`. These denials count toward the agent's `network.agent.off_task_rate` in [network signals](https://provenanceauth.com/docs/authorize/guides/use-network-signals.md), past the usual minimums, so a maker whose subagents drift shows a visible rate.

## Errors you might see

| Code | What to do |
| --- | --- |
| `purpose_tags_exceed_parent` | Use tags from the parent's action types or counterparties. |
| `insufficient_role` | Change the settings as an owner or admin. |
| `insufficient_scope` | Use a key with the `admin` scope to change the settings. |

## See also

- [Delegate to subagents](https://provenanceauth.com/docs/mandate/guides/give-subagents-their-own-limits.md)
- [Policies](https://provenanceauth.com/docs/concepts/policies.md)
- [Use network signals in policy](https://provenanceauth.com/docs/authorize/guides/use-network-signals.md)
