
# Managing agents

**Your agents** in the console lists every coding agent and deploy key that works as you: connect a waiting agent, change what one may do, or revoke it. Open it at `/console/account/agents`. Changes apply from the agent's next request, so there is nothing to restart.

Each action confirms in a note at the top; a revoke reads "Revoked. It can’t make another request, and the copies of production it used are being deleted."

## Ask your agent

```text
Run agc whoami. If you're not connected to me yet, give me the link to connect you.
```

You get a claim link, or confirmation of your name, organization and the agent's purpose.

## Do it in the console

1. Open the menu at the bottom of the left sidebar (your initials and email) and choose **Your agents**.
2. On a **Waiting for you** row, choose the organization (if you're in several) and a purpose, then press **Connect**.
3. On a **Connected** row, pick a purpose and press **Change purpose**.
4. On a waiting or connected row, press **Revoke**. It acts at once, with no confirmation.

As an organization owner, revoke another member's agent from **Members** > **Agents** tab > **Revoke**.

## Steps

A revoked or expired agent never connects again. Make a replacement:

```bash
agc init --reset-identity
```

The person connects it in the console, or makes a **Start an app** join code for `agc init --join <code>`. Then `agc whoami` reports `"state": "connected"` and the chosen purpose.

## How it works

An agent belongs to one person in one organization, for good. You usually connect it when you claim or publish its app (**Claim and connect** or **Publish and connect** on the claim page) or approve its first release (**Approve and connect**). After **Approve only**, it follows that one release until you press **Connect** or 7 days pass. It works only on apps you may build in its organization. A machine holds one agent per organization, so one laptop can have several rows.

Under required company sign-in, **Connect** and **Change purpose** may send you through it first ([Console sessions](/docs/owners/company-sign-in-and-scim.md#console-sessions)); **Revoke** works from any session.

### Narrowing a purpose

Narrowing counts as a loss of access for whatever was dropped:

| Moving off | Ends |
|---|---|
| A shipping purpose (Builder or Ship-only) | Its releases no person approved that haven't started on production |
| A purpose that uses copies (Builder or Mirror-only) | The masked copies it was given |
| Task tokens (a deploy key, to any other purpose) | Every task token it minted |

To stop an agent shipping for a while, pick Mirror-only rather than revoking, which is permanent: it keeps working on copies and you can widen it later.

### What revoking cleans up

It runs whenever a credential loses access (revoked, expired, removed, or its person lost the app), at once and retried until done.

| What | What happens |
|---|---|
| Its next request | Refused with `auth.invalid` |
| Its releases | Those no person approved that haven't started on production are cancelled ("Cancelled before it reached production: the agent that shipped it lost access to the app."); others finish |
| Masked copies | Every copy it made or was given is deleted; other agents using one lose uncommitted work and run `agc up` |
| Connection credentials that reached a copy | Can't be withdrawn: **Connections** shows **Rotate these credentials at the provider**, then **Mark rotated** |
| A deploy key's task tokens | End with it |
| Running apps; data already on its machine | Apps keep running; the data can't be recalled |

## Agent identities and purposes

An agent is one agc installation's identity, created by the first `agc init` on a machine, with no account needed. Only a person's click in the console connects it, with a purpose. `agc whoami` shows where it stands.

| State | What it means |
|---|---|
| Unclaimed | May create up to 3 apps; every answer carries `claim_by`, and `agc init` prints a `claim_url` to relay. **Claim and connect**, **Publish and connect** or **Approve and connect** connects it; **Approve only** leaves it waiting. After 7 days unconnected it expires and its unclaimed apps are deleted. |
| Waiting | May run `agc whoami` and follow its one operation; anything else answers `agent.not_connected` with a link to connect it. Same 7-day deadline. |
| Connected | Every request reads its current record. It expires after 30 days without a successful request or 90 days after connecting, and nothing refreshes it (`auth.expired`). |

How agc stores one agent per organization, sets an old one aside on `--reset-identity` (refused while `AGC_TOKEN` is set) and keeps staging agents from production: [Local state](/docs/reference/agc-environment-variables.md#local-state).

### Purposes

| Purpose | The console says | What it may do |
|---|---|---|
| Builder | Work on and ship your apps, with masked copies of production data | Everything Mirror-only may, plus create apps, ship, generate secrets, request connections, relay its person's in-session approvals |
| Mirror-only | Work with masked copies, never ship | Read; use masked copies (mirrors, `agc db query --env prod`, `agc capsule`); send feedback |
| Read-only | Look, change nothing | Read status, logs, review, schema, secret names, context, connections, approvals; nothing that changes anything or hands out access |

### Credential kinds

| Kind | Prefix | Made by | Purposes |
|---|---|---|---|
| Agent | `agc_…` | first `agc init` | Builder, Mirror-only, Read-only |
| Deploy key | `agcd_…` | a person, in the app's settings (1 to 90 days, default 30) | Builder, Mirror-only, Ship-only, Task tokens, Verifier |
| Task token | `agct_…` | a Task tokens deploy key (5 to 60 minutes, default 60) | fixed: its task's sandbox |

A deploy key works on its one app only, is read from `AGC_TOKEN`, and never records an approval; its purposes are on [Deploy keys](/docs/ship/ci-cd-with-deploy-keys.md), task tokens on [Hosted builders](/docs/ship/work-tab-and-builders.md#tasks-and-task-tokens). For a key, **Change purpose** offers Builder, Mirror-only and Ship-only.

## Reference

**Who acts where.** Only the person an agent or key works as sees it on **Your agents**. Builders see **Members** > **Agents** view only. The app's owner or an organization owner can also revoke a key in the app's **Settings** > **Deploy keys**.

**Rows** are **Waiting for you**, **Connected**, **Revoked** or **Expired**. An ended row says why: revoked by its person, not connected within 7 days, unused for 30 days, 90 days after it was connected, its person left the organization, its person was removed by the identity provider, or removed from the organization (by an owner, in **Members**).

**`agc whoami`** returns the fields in the [CLI reference](/docs/reference/cli-reference.md) (`owner` is the person), plus `default` (this machine's default agent) and, for a task token, `slot`, `work` and `key`.

## Errors

Refusals are checked in this order: `auth.invalid`, `auth.expired`, `agent.not_allowed`, `agent.not_connected`, `app.unavailable`, `agent.purpose`, `app.claim_first`, `auth.no_identity_for_org`. For the first two, run `agc init --reset-identity` and have the person connect the new agent, or replace an `AGC_TOKEN` key. Every code, its exit and fix: [Error code catalog](/docs/reference/error-code-catalog.md).

In the console, "That agent can’t be connected any more: it’s past its deadline, revoked or expired." means make a new agent.

## Limits

Agent, key and task-token lifetimes and the 20 live task tokens per key are in [Limits and quotas](/docs/reference/limits-and-quotas.md). An unclaimed agent may hold 3 unclaimed apps, and **Your agents** shows 200 rows, live ones first.

## Agent notes

- After `agc init --reset-identity`, the person must connect the new agent before it can touch a claimed app.
- Your label (Claude Code, Codex, Cursor) is self-reported. `next` names only commands your purpose allows.
- If the app's activity says "Removed copy …: an agent that used it lost access to the app", run `agc up` for a fresh copy.
- An ended agent stays ended; the fix is always a new one (`agc init --reset-identity`) that the person connects.

## Related

- [Claiming an app and connecting your agent](/docs/getting-started/working-with-your-coding-agent.md#claiming-an-app-and-connecting-your-agent)
- [Deploy keys](/docs/ship/ci-cd-with-deploy-keys.md#replacing-and-revoking-a-key)
- [Members, roles, invites, join requests](/docs/owners/members-roles-invites-join-requests.md)
- [What agents can and can't do](/docs/concepts/what-agents-can-and-cant-do.md)

<!-- feedback:start -->
---
Wrong, outdated or unclear? Run `agc feedback docs "owners/managing-agents: <what is wrong>" --body <file>` with the sentence quoted in the file. No code or app data is sent.
<!-- feedback:end -->
