Wallets: one budget for a task tree#

A wallet is one budget that many tasks draw from. Use it when one piece of work runs as many sessions or processes: an orchestrator that starts claude -p or codex exec many times, a retry that starts a fresh session, a CI job that fans out. This page is for developers who start agents from scripts, and for team leads who want one limit for a whole job.

What a wallet does and does not do#

Each child keeps its own task, with its own budget, cache, loop and drift tracking. Every call of a task in the wallet is also held to the wallet. Lockpin checks the wallet in the same locked step as every other limit of the call, before the call leaves the machine, so parallel children through one Lockpin can never together pass the wallet.

A wallet never raises a budget. A task in it is still held to its own budget, the machine’s day limit, and its key’s, team’s, project’s and policy’s limits.

Start a run in a wallet#

lockpin run -wallet 20 -- ./orchestrate.sh

lockpin run -wallet opens a wallet named after the run’s task (the git branch) and points the agent’s base URLs at it: http://127.0.0.1:8787/w/<wallet>/t/<task>/anthropic. Every process the agent starts inherits those variables, and in-process subagents use their parent’s base URL, so no client needs a change. A lockpin run without -wallet opens no wallet.

To put a shell in a wallet yourself:

eval "$(lockpin wallet open migrate-auth -usd 20 -child-usd 2)"
./orchestrate.sh

On Windows, lockpin wallet open prints PowerShell lines; run them, or pick another form with -shell. A framework that sets headers can send X-Lockpin-Wallet: migrate-auth instead.

How calls join a wallet#

  • The first call of a named task (X-Lockpin-Task, /t/<task>/, a session) that names a wallet joins it, and the task stays in it: later calls of that task are held to the wallet whether they name it or not, until the wallet ends or a person takes the task out (lockpin wallet unlink).

  • The default task is never joined for good: a call of it is held to the wallet it names, and only that call, so your other work is never stuck behind a wallet.

  • A task cannot move to another wallet (409 wallet_conflict), only to a wallet inside its own.

  • -child-usd caps what each new task in the wallet starts with. It only ever lowers a budget.

  • A wallet opened inside another (LOCKPIN_WALLET set) is its child: the children of both share the outer wallet too, at most 8 deep.

  • In team mode a call joins only wallets of its own key, and team wallets an admin of its team opened (lockpin wallet open NAME -usd 50 -team backend).

Set part of a wallet aside for one task#

By default the tasks in a wallet share all of it, first come, first served. When one child must not be starved by the others (a reviewer that runs last, a final merge step), set part of the wallet aside for it:

lockpin wallet earmark migrate-auth reviewer -usd 3

From then on the wallet holds $3 for the task reviewer, less what that task has spent in the wallet since and has in flight. A call of any other task must fit in what is left after the part still held, and is refused if it does not. lockpin wallet show migrate-auth lists each earmark with what was used and what is still held, as of the time shown; the meter’s Wallets panel shows the same, with a Set aside button on each open wallet and a Release button on each earmark.

An earmark only restricts:

  • It raises nothing. The wallet’s ceiling, the task’s own budget, the day limit and every key, team and policy limit stay as they are. The earmarked task is refused exactly where it would be without the earmark.

  • It is a floor for its task, not a cap on it. Once the task has used its earmark it draws on the rest of the wallet like any other task.

  • Earmarks cannot add up to more than the wallet, and each wallet it is inside, has left. A set that does not fit is refused (earmark_too_large). An earmark is a cent or more.

An earmark in a wallet inside another holds in the outer wallet too, so a task directly in the outer wallet cannot spend what the inner one set aside. lockpin wallet show on the outer wallet says how much of what it holds was set aside by wallets inside it. This reaches as far up as the wallets were opened by the same key or team: a member’s own wallet inside a team wallet holds only in itself, so no member holds room their teammates share.

What the task has not used returns to the wallet when you release it (lockpin wallet earmark migrate-auth reviewer -release), when the task has made no call in the wallet for 30 minutes and has none in flight, when the task is taken out of the wallet, or when the wallet, or one it is inside, ends. You can set an earmark before the task’s first call, then start the child; if the child never runs, the earmark returns after 30 minutes.

Who may set one, and how much#

Whoever may close the wallet may set an earmark in it: on a single machine any process on it, in team mode a member in wallets of their own key (for their own tasks) and an admin in team wallets.

What a process can do without a person is limited, so an agent cannot set a whole wallet aside for itself:

  • Earmarks set without a person hold at most half of a wallet’s ceiling between them, in each wallet they hold in. The other half is always open to every task.

  • A wallet takes at most 200 of them a day.

  • None is set or released in or around a strict wallet (the strict wallet, a wallet inside it, or a wallet with an open strict wallet inside it): a strict wallet holds your own unrelated sessions too.

To set one as a person, add -person at a terminal:

lockpin wallet earmark migrate-auth reviewer -usd 12 -person

The command asks for a y and then sends the control token. From a script or a pipe it refuses, so a script cannot make itself a person this way. An earmark set like this, on the meter page, or by an admin on a team server is a person’s: it is outside the limits above, and only a person changes or releases it. In or around a strict wallet the command always asks. A wallet holds at most 100 earmarks; a person’s set in a full wallet takes the place of the earmark no person made that was used least recently.

On a single machine the control token is a file an agent running as you can read, so these rules slow an agent down there; they are not a wall. A team node, where the token and keys sit under another account, makes them one.

When a call is refused because of an earmark, the message says so:

lockpin: wallet "migrate-auth" has $0.66 left of $20.00, $0.60 of it set aside for other tasks (as of 14:05:09 UTC); this call needs up to $0.17. Stop and report what is done to whoever started you.

What Lockpin cannot see#

A child that drops the marker (a script with a hardcoded URL) goes through Lockpin as its own task, outside the wallet. It is still held to the machine’s day limit (or its key’s limits in team mode). A child that holds the provider key and calls the provider directly is not seen at all.

-strict closes the first gap on one machine: while a strict wallet is open, calls that name no wallet are charged to it when it is the only strict wallet, and refused (wallet_required) when there are two. A new task cannot leave it by naming another wallet, only one inside it. It catches your own unrelated sessions too, so on a single machine opening or closing one, and opening any new wallet outside it while it is open, need the control token, which lockpin wallet reads for you. On a team server only an admin opens one.

The meter and lockpin wallet show say how much was spent outside any wallet while a wallet was open, so the gap is visible.

When the wallet runs out#

The call that does not fit is refused with 402 budget_exceeded, a wallet object with its figures, and a message the child’s CLI prints and a subagent carries back to its parent:

lockpin: wallet "migrate-auth" has $0.40 left of $20.00 (as of 14:05:09 UTC); this call needs up to $1.10. Stop and report what is done to whoever started you.

Every reply of a call in a wallet carries X-Lockpin-Wallet-Left-Usd (what the call’s task may still use: what is left, less what is set aside for other tasks) and X-Lockpin-Wallet-As-Of. With the budget note on, each call ends with a second line, numbers only: [Lockpin] Wallet for this task tree: $0.40 of $20.00 left (as of 14:05:09 UTC); 1 sub-agent was refused in the last 5 minutes.

A wallet’s refusal is final, like a key’s limit: the meter does not hold the call for a yes. To give it more, lockpin wallet raise NAME -usd 30 at a terminal. That is a loosening: once a day within the allowance, otherwise a person confirms it (a passkey, where you have one; without one, the control token, and Lockpin says it was not confirmed to be a person). With a passkey, finish it on the meter: the Wallets panel’s Raise button asks for the tap, and Take a task out does the same for lockpin wallet unlink. The alert it raises names the wallet to your own alert destinations.

Ending a wallet#

Closing a strict wallet, or a wallet with an open strict wallet inside it, is asked about at a terminal and needs the control token (an admin on a team server): the first frees the calls the strict wallet caught, the second leaves them refused.

lockpin wallet close NAME ends it at once: a call that names it (a child still pointed at it) is refused from then on, and the name is not used again. An ordinary wallet’s tasks’ calls that name no wallet then go back to their own budgets and the backstops, so a branch’s task works again after its run’s wallet ends. A strict wallet’s tasks stay stopped, whatever their calls name, until a person runs lockpin wallet unlink TASK or uses Take a task out on the meter: an unattended run that hit its wallet stays stopped. The default task is never held this way. A wallet also ends at its expiry, 24 hours unless you gave -expires (at most 30 days). The meter’s Wallets panel has a Close button for each open wallet, and lists wallets that ended in the last week; lockpin wallet show -all lists every one.

To keep wallets from piling up, opens made without a person are capped: one key may have 100 open and open 200 in a day, one machine 500 a day, one Lockpin 1,000 open. Your own opens (with the control token, which lockpin wallet and lockpin run -wallet send, or by an admin) are not counted, so a process that churns wallets cannot stop you opening one.

Several machines#

A wallet lives in one Lockpin’s ledger. Machines that each run their own Lockpin each have their own wallet; only calls through one Lockpin (or one team node) share one wallet atomically. Nothing about a wallet or its earmarks is uploaded to the dashboard.

All flags are in the command reference.