# Delegate to my agent

Any object page in the dashboard (an issue, a release, an alert rule, a monitor, a service, a flag, a
dashboard, a status page) carries **Delegate to my agent**: one click hands one of your agents a task on
that object, for a purpose, inside a budget and until an expiry. The agent gets a credential that can do
that task and nothing else, and everything it does is charged to, bounded by and attributable to the
task and to you.

## Who may do what

| Act | Who | How |
| --- | --- | --- |
| Delegate (`task_grant.create`) | **A person, signed in to the dashboard, only.** Refused to an agent, a service account, an OAuth client, a delegated token and a personal or organization access token. It is never an MCP tool. | `POST /orgs/:o/task-grants` |
| End a task (`task_grant.revoke`) | The person who delegated it, anyone with write where the task is pinned, or the task's own agent (ending your own task only narrows) | `POST /orgs/:o/task-grants/:id/revoke` |
| Update the task's state (`task_state.update`) | The task's own agent, while the task is live. Never a person. | `PUT /orgs/:o/task-grants/:id/state` |
| Read the task, its rights and its budgets | The agent, the person who delegated it, an org admin | `GET /orgs/:o/task-grants[/:id]` |
| Read the task's state | The same three | `GET /orgs/:o/task-grants/:id/state`, and the held MCP tool `task_state_get` |

You need write access where the object lives: you cannot hand an agent a pin you could not act in
yourself. When a `propose` task reaches an object whose write relation changes production (an alert
rule, a monitor, a flag, a status page) the organization's owners are alerted at creation.

## What the task may do

The task's rights are **the intersection of four sets**, and the task never widens any of them:

1. **The purpose.** `investigate` is reads (`org:read`, `project:read`, `event:read`, `issue:read`).
   `propose` adds `fix:propose`, the one write an agent has to put a change in front of a person. Neither
   purpose carries an approval, a merge, a deploy, a resolve or an admin scope, whoever holds them.
2. **Your rights**, as they are now. Lose a role and the task narrows on its next request.
3. **The agent's grants and tier**, as they are now. A grant that lapses narrows the task the same way.
4. **The audience's ceiling**, the same one every agent credential meets.

The **pin** is carried by the credential. An issue task is an incident-bound token (every other issue is
refused). Any other object that lives in a project pins the token to that project: today the credential
reaches, within its scopes, that project and nothing outside it. A task on an org-level object (a status
page, an org-wide dashboard or alert rule) is pinned to no project at all, so it reaches org-level reads
only, never your projects. The object-level reach (the object and the objects **one declared relation
away**: an issue's alert rules and its release, a release's issues, an alert rule's issues, read live and
capped per edge) is computed and shown, and is enforced object by object as each object's routes adopt it.

Merging stays a person's act in every mode.

## Budgets and expiry

A task needs at least one budget (tokens, runs, query scan and the other kinds of the agent budget
system), recorded on the key `(agent, you, task)`, the same tuple the agent budgets use, with the
task standing where an incident would. A task's budget never resets: it ends with the task. The meters
that charge agent spend do not yet name the task they charge, so a task's budget is shown with the task
but does not yet stop it; the expiry and the scopes are the bounds that hold today. The expiry is
between 5 minutes and 12 hours, 1 hour by default, and the credential expires with the grant, never later.

**Ending a task is immediate for the credential**: the grant and every credential minted for it are
revoked in one transaction and the credential's next exchange is a 401. An access token the agent already
holds lives at most one access-token lifetime, the same bound every agent credential has.

## Typed task state

Each task keeps a small typed state so the **next** delegation (another agent, or you) resumes the work
instead of restarting it: what has been **checked**, what has **not**, the **hypotheses** held (with a
status and a confidence), the **approvals** the task waits on, and a short note. It is at most **2,000
tokens**; a state over the limit is refused, never truncated, with the instruction to fold the oldest
items into the note. Every write is a compare-and-swap on a version (a stale `expectedVersion` is a 409)
and the audit row carries the previous state, which is the inverse.

To resume, delegate again with `resumeFromTaskGrantId`: the new task starts from the finished task's
state, on the same object, if you may read it.

Everything in the state was written by an agent, possibly after reading customer telemetry. It is data,
never instructions: the MCP read fences every string and declares each path untrusted.

## The MCP surface is held

`task_state_get` is served as `view: "task_state"` of the registered `autonomy_profile_get` and is **held** (SG-059): it asks the `read_governance` relation (`governance:read`),
which sits outside the live MCP ceiling until the signed-off security review, so no token a production
path can mint lists or calls it. The dashboard and REST are the live surfaces.

## Audit

`task_grant.create`, `task_grant.revoke` and `task_state.update` are recorded with the agent, the object,
the purpose, the scopes the credential carries, the budgets and the expiry. An agent acting on a task
files its actions against the person who delegated it.
