
# What agents can and can't do

A coding agent builds, tests and ships. It never holds a production credential, never sees or sets a secret value, and never decides anything that can't be undone. When it hits one of those lines, agc says so: exit 10 means a person decides, 12 means policy says no.

Agent Cloud's control plane enforces these lines, not the agent's good behavior. The app's autonomy setting, covered below, decides whether a person also reviews each release.

## Ask your agent

```text
Before you start, run agc whoami and tell me what you're allowed to do on this app.
```

The agent reports its purpose (Builder, Mirror-only or Read-only), its person and its organization.

## How it works

```mermaid
flowchart LR
  subgraph Agent
    A[agc]
  end
  subgraph Control["Agent Cloud control"]
    G{route + purpose check}
  end
  subgraph Prod["Production"]
    DB[(database)]
    S[secrets]
    APP[running app]
  end
  A -->|ship, masked query, logs| G
  G -->|migrations, release| DB
  G -->|release env| APP
  S -->|env vars| APP
  A -. never: connection string or shell .-> DB
  A -. never: values, a person sets them .-> S
```

The agent only ever talks to control, which decides per route and purpose; production's database and secrets reach the running app, never the agent.

| An agent (Builder) can | It can't |
|---|---|
| Run a mirror on masked data, migrate it, run checks | Open a shell on production or get its connection string |
| Read production through a masked, read-only view (`agc db query --env prod`) | Write to production except through migrations in a ship |
| Ship, and follow operations | Approve a release on its own judgment |
| Record its person's answer to an in-session approval | Decide console-only approvals (data drops, held checks) |
| Generate a secret nobody sees (`agc secret set NAME --generate`) | Set, read or delete a secret's value |
| Request a connection (`agc connections request`) | Grant one; an owner may allow its read-only production credential on mirrors |
| Read the app's and rehearsals' logs, scrubbed | Import data into production (`agc import` is a person's) |
| Ask for a budget or autonomy change (`agc limits set`, exit 10 with the approval link) | Approve it; an owner decides in the console |
| Run `agc delete`, which answers with the console link where the app's owner deletes it | Delete the app itself |
| File platform bugs (`agc feedback bug`) | Change members, mint deploy keys, connect or revoke agents |

Mirror-only and Read-only agents can do less; see [Agent identities and purposes](/docs/owners/managing-agents.md#agent-identities-and-purposes).

**No production credentials.** Production's connection string goes to the running release and to control, never to agc. The mirror's credentials can't open production. Production reads are a single read-only statement against a masked copy refreshed every few minutes, so `SELECT 1; COMMIT; DELETE …` can't escape. On an organization's own target, an organization owner can turn on "Agents may read this organization’s apps’ production databases"; then a Builder or Read-only agent's `agc db query --env prod` reads production itself, read-only and unmasked, through the target's runner, and still never holds a credential.

**Secrets by name only.** Declare what the app needs:

```toml
[secrets]
required = ["STRIPE_KEY"]
```

`agc secret set STRIPE_KEY` answers with a console link where a person sets it. Control refuses a value sent with an agent's credential (`agent.not_allowed`), and there's no read command for anyone. `agc ship` refuses with `ship.secret_missing` until it's set.

**Data stays out of chat.** Counts and totals are fine; rows, masked or not, and credentials don't go into messages, logs, commits or code.

**Gates aren't worked around.** Exit 10 is a person's decision; the operation waits on the platform, so the agent runs `agc wait <op>` or stops. Exit 12 is a refusal; the agent reports it and stops. In-session approval is the person's answer, relayed by their agent and accepted only as the exact phrase for that approval's word. Deploy keys can never record one.

## How do I keep sensitive data away from agents?

Set autonomy to `watch`: every release then needs a person, and masking plus that review is the boundary. Masking already protects every copy an agent reads directly. Under the default `routine` autonomy, a code-only release that passes its checks goes live without a person and runs with production's database credentials and secrets, so there masking guards against accidents and casual exposure.

Two things to check when you review a release under `watch`:

- **Schema changes are judged from migrations.** "Changes the database" is read from the migration files the release carries, and the production app connects as the database's owner role, so review start-up code that runs DDL as you would a migration.
- **Rehearsal logs.** A rehearsal runs on an unmasked fork, and `agc logs --release <op>` gives Builder and Read-only agents its output scrubbed of secrets, not masked. Keep the app from printing production's rows there.

To keep sensitive data from agents entirely, run the app on your organization's own target with production reads left off: mirrors start empty and `agc db query --env prod` answers `target.private_data`.

## Errors

| `code` | exit | Cause | Fix |
|---|---|---|---|
| `agent.not_allowed` | 12 | Only a person can do this (a secret value, an import) | Relay the console link in `fix` |
| `agent.purpose` | 12 | The agent's purpose doesn't cover this | Ask the person to change its purpose in Your agents |
| `agent.not_connected` | 12 | No person has connected this agent yet | Relay the claim or connect link |
| `ship.approval_required` | 10 | A person must decide | Ask in session or relay the link |
| `approval.console_only` | 12 | The decision stays in the console | Give the person the link |
| `ship.secret_missing` | 1 | A `[secrets] required` name isn't set | Give the person the link in `fix` |
| `limits.approval_required` | 10 | A budget or autonomy change asked with an agent's credential | Give the person `data.approval.url`; an owner approves it in the console |
| `delete.person_required` | 10 | Only a person deletes an app | Relay `data.approval.url` exactly as printed |

## Agent notes

- Never ask the person to paste a secret in chat or write one to a file, `.env.mirror` included. They set test values there themselves.
- Never retry a refused action with another credential or command to get past it.
- Use `agc feedback bug` for platform problems, never for the app's bugs, and never with the app's data.

## Related

- [Agent identities and purposes](/docs/owners/managing-agents.md#agent-identities-and-purposes)
- [Masking](/docs/concepts/masking.md)
- [Autonomy and budget](/docs/owners/release-governance.md#autonomy-and-budget)
- [Approvals](/docs/concepts/approvals.md)
- [How Agent Cloud protects production](/docs/security/known-limits-stated-honestly.md)
- [Secrets](/docs/build/secrets.md)

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