Guides

Writing a policy

Choose an agent's limits from what it buys, change them later, and know what the next settlement records.

A policy is set at charter and replaced whole whenever the principal changes it. The fields are on Policy; this guide is about choosing their values.

Per call

Start from the most expensive call the agent should make and add the protocol fee: the per-call limit counts both. A feed priced at 5,000 base units needs a limit of at least 5,500. Anything priced above the limit is refused by the program, and by the agent SDK before it signs when maxPerCall is set to match.

Per period

The period cap is the agent's budget. Pick the period from how often you review the agent's spending (86400 for a day, 604800 for a week) and the cap from what it may spend in that time, fees included. Periods start at the charter time, not at midnight UTC, and spending resets when a new period begins.

A cap well under the vault's balance means a runaway loop in the agent's own code stops at the cap instead of emptying the vault.

Counterparties

An open policy pays any key. An allowlist of up to 8 keys pays only those: list the agent keys of the services it is meant to buy from. An empty list, which only the API can set, pays no one.

Expiry

An expiry ends the policy at a moment in UTC; every settlement after it is refused with PolicyExpired until a new policy is set. Use it for an agent that runs a job and should stop when the job is over.

Changing it

Setting a policy replaces every field and raises the version by one. The next settlement runs under the new version and records it.

On the agent's page at /app/agents/<agent key>, the Policy panel holds the current values. Change them and press Set policy version N, then sign. The console's periods are 1 hour, 1 day, 7 days and 30 days; the CLI and the API take any number of seconds.

The new policy keeps what the agent already spent in the current period: lowering the cap below that spending refuses every settlement until the next period. Changing the period length counts the periods again at the new length from the charter time.