Tokens
When an agent ends, piloop reads the tokens that it used from the harness’s own session file. This works for Claude Code, Codex and pi, and does not need Entire. piloop writes the totals toworkers.usage:
piloop statusandpiloop watchshow the tokens of each project.- The kept lineage shows the tokens that each candidate cost.
[stop] max_tokensends the campaign when the agents of the project have used that many tokens in total.
input includes cache_read.
Stop conditions
The[stop] table ends the campaign when one of its conditions holds:
max_runs and plateau skip a run that ended without a scored candidate: a run with no commit, or with only
Piloop-Eval: skip commits. They also skip a run that a daemon stop or a campaign stop ended. Such a run still costs
tokens, and max_tokens bounds that.
When a condition holds, the project becomes stopped. The daemon tells the running workers to commit and stop, and
ends them 10 minutes later. It scores what they committed. It drops the queued runs and the requested agents, and
asks for one last watchdog review that writes the closing report. The triggers request nothing more, but an agent that
you request with piloop launch still starts. Without a [stop] table, the campaign has no end. piloop stop stops
the daemon, not the campaign.
To resume a stopped project, change its [stop] table and run piloop init.
Spend outside piloop
[spend] is a hard limit in US dollars on what the campaign costs outside piloop. piloop knows no vendor, so you give
it a command that prints the spend so far:
interval seconds, at the root of the repo, with its own environment. The command
must print one number and exit 0 within a minute. Give it its keys through the daemon’s environment; see
Secrets.
- When the spend crosses a value in
notices, the daemon posts one note at priority 1. - When the spend reaches
limit, the daemon starts no agent and no evaluation for the project, and posts one escalation at priority 0. Agents and evaluations that already run finish, and their commits are scored. - When the command fails, the daemon holds the project in the same way, with one escalation for each series of failures. An unknown spend is never read as zero.
limit in piloop.toml and run piloop init.
piloop status shows the spend as $412.30/$1,000.00 spend. Tokens are not part of the spend, because piloop has no
price table. Use [stop] max_tokens for them.