# Manage agent budgets

> Limit each agent's accepted queries, writes, destructive writes and exports, and read what remains.

Canonical page: https://anectico.com/docs/manage/agent-budgets/


An agent here is one management API key or one approved agent connection. Its budget counts
accepted operations. It does not count money, tokens, tracked people or model calls.

Retries are free when they carry the same supported retry key or confirmation. A fresh key or confirmation starts new work. Keep the retry key from the original call.

## Set limits

A workspace owner or admin can edit limits beside a management key in **Agents and keys**, or
beside a connection in **Connected agents**. The API keys card also controls the workspace defaults
and an optional total across all agents.

Set limits per UTC hour and day for queries, writes, destructive writes and exports. Also set how
much work may run at once. An empty agent limit inherits the workspace default. An empty workspace
default inherits the platform default. Zero blocks that class. Empty workspace totals impose no
extra total cap. Tightening a limit takes at most seven seconds and needs no new sign-in. Work already
admitted can finish.

| Class | Platform per hour | Platform per day |
| --- | ---: | ---: |
| Queries | 3,000 | 30,000 |
| Writes | 600 | 5,000 |
| Destructive writes | 60 | 300 |
| Exports | 60 | 300 |

The platform default allows 16 operations at once. The defaults are a safety net against a
runaway loop, not a limit on ordinary work: tighten them for an agent that should do less. Operation limits accept whole numbers from
0 to 1,000,000; concurrency accepts 0 to 64. These are work controls, not a price quote.

## Read what remains

Ask for the current budget with `anectico budget get` or the MCP read action `get_agent_budget`.
It returns the effective limits, accepted counts, work reserved during admission, remaining work,
and the absolute UTC start and reset time for this hour and today. Read history with
`anectico budget usage --period day` or `get_agent_usage`. The history is a record of accepted work,
kept for 35 days by hour and 13 months by day. It can lag and can lose unrecorded work during an
outage. Missing history is unknown, not proof of zero. The history conclusion describes the
returned buckets, not a count of all agents that reached a limit.

A credential needs `activity:read` for its own policy and usage. Reading another credential or
workspace defaults needs `audit:read`. An owner can use `anectico budget get --credential-kind
api_key --credential <key-id>` or the same arguments on `anectico budget usage`. A project-bound
credential cannot read another project's policy or history. For defaults use
`anectico budget get --workspace`.

`anectico budget set --file budget.json` replaces an override. A key policy file can be:

```json
{"credential_kind":"api_key","credential_id":"<key-id>","policy":{"queries":{"hour":20,"day":100},"concurrent":2}}
```

Omit both credential fields to replace workspace defaults. Add `workspace_total` to that file to
cap all agents together. Setting a policy needs `api_key:write` and an owner/admin role; changing a
connection also needs `members:write`. Over MCP, use the confirmed write action `set_agent_budget`.

## What counts and what happens at a limit

Accepted query executions, applied writes and exports count. Refusals, previews, configuration
list/describe reads, result polling and identical retries do not count. Native safety limits still
apply. A new query execution key deliberately means new work. Retry identities for other operations
last ten minutes; keep the original identity when retrying. Creating a fresh key creates a fresh
individual budget, so only a person with key-management rights can do that; a workspace total
keeps that within the owner's overall allowance.

A refusal carries `budget_refusal`: `class`, `limit_kind` (hour, day, concurrency or unavailable), `limit_value`,
`resets_at` in UTC, `subject` (agent, workspace or an identical operation), `owner_can_change` and `reason`. REST returns
429, MCP returns a tool refusal, and the CLI exits 1 with the same fields. A running identical
admission can briefly return `operation_in_progress`; it has no charge. The activity record marks
budget refusals as `budget`. A concurrency reset is the current earliest running lease expiry;
running work can extend it.

If the budget cannot be checked, queries continue with an explicit unchecked marker. Writes and
exports stop with `budget_unavailable` and a short try-later time. Current counters may be lost
during an outage or when cached state is reclaimed, so a budget is an operational limit,
not a financial guarantee. Never retry a refusal in a loop. Tell the person which limit was
reached and when it resets, or that checking was unavailable.

## Ask your agent

The agent uses `get_agent_budget` for what remains, `get_agent_usage` for history, and
`set_agent_budget` for an approved change.

> How much work do you have left this hour and today? Tell me the limits, the UTC reset times,
> and whether the counts were checked. Stop if you reach a limit.

> Show the accepted usage for this key this week. State the time window and any gaps in the record.

> Set this key to 20 queries an hour and 100 a day, with two operations at once. Preview the exact
> change before I approve it.

## Scheduled work

A report, alert rule, metric watch, Live screen or sampling rule records which key or connected
agent created it. Changing its query, schedule or targets moves the origin to the updater. A rename
or pause does not. A Console member creates a person origin without a member id.

Each accepted scheduled run counts once. A retry of that run is free. Revoking or expiring the key,
or removing the connection, moves new runs to **scheduled work** in the workspace. Reports and
alerts keep working. Person-created and older definitions use that same line. Only the optional
workspace total limits this work.

Reports, Live refreshes and sampled evaluations skip an exhausted slot. They show `budget_exceeded`
and try at the next scheduled time. Alert and metric-watch evaluations always run. Missing an alert
is worse than an overage. Usage marks **over budget by scheduled alerting**; these counts are part
of accepted work, not an extra charge. Alerts take no concurrency slot, even at a workspace limit.

If limits cannot be checked, Live refreshes and alerts run with `checked: false`. Reports send data
and evaluations write results, so both skip with `limits_unavailable`. These skips do not retry in
a loop. Opening or polling a Live display is free. Experiments run when called; release gates read
recorded evidence. They follow the usual interactive limits.

The API keys card shows a **Scheduled work** usage line. Ask your agent for `get_agent_usage` with
`credential_kind: scheduled_work`, or run `anectico budget usage --credential-kind scheduled_work`.
Use no credential id. This workspace read needs `audit:read` and workspace access. Read the returned
UTC window and its uncertainty. Add this line to the credential lines for the same period and window.
Do not add hour counts to day counts. Missing history is still unknown.

Each feature's usual read shows its origin and latest run budget state. Credential names require
`api_key:read` for a key or `members:read` for a connection; a missing name may be withheld or
unavailable. A revoked publishing key still stops public Live viewing. To stop a schedule itself,
pause or delete its definition. Revoking its accounting origin does not cancel it.
