Caps and budgets
Kraft bounds a work item two ways: loops limit how often it repeats, and caps limit the time, tokens and dollars a scope may use. Scopes nest, so a day holds work items, a work item holds nodes, a node holds steps and a step holds tasks. Whichever bound runs out first stops the item and hands it to you instead of failing it.
For every key and its default, see policy.yaml, and for the caps the shipped chains set, The default caps. To raise a cap that stopped an item, see Raise a cap on a stopped item.
Two kinds of bound
Kraft bounds work in two ways.
- a day, since local midnightevery work item together; budget.daily_usd, dollars
- a work itemtime, total time, tokens, dollars, and budget.work_item_usd
- a node, a gate includedtime, total time, tokens, dollars
- its fix loop[↻ attempts, wall clock]bounds repetition, not resources
- a steptime, total time, tokens, dollars
- a tasktime, total time, tokens, dollars
- a node, a gate includedtime, total time, tokens, dollars
- a work itemtime, total time, tokens, dollars, and budget.work_item_usd
Loops bound repetition. A fix loop retries a node until it passes. Its
attempt limit is max_attempts in the chain (attempts under loops: and
default: in policy.yaml). Its wall clock is wall_clock_s there.
An external wait (a pipeline, an automated review, an approval, a merge
landing) isn't a loop. Its timeout is its own task's total_time_cap_minutes.
Caps bound a scope's resources: time, tokens and dollars. Below the day, a scope is the work item, a node, a step or a task, each inside the one before.
Whichever bound runs out first stops the item, and the stop names its scope. What a cap stop says has the wording.
Only a person resets a loop's count. A retry from the board or from
kraft item retry starts the fix loops of the retried
span afresh. A retry that a worker, an MCP
assistant, an escalation turn or a
rate-limit relaunch asks for keeps counting. See
Fallback and escalation.
A gate rejection is the one exception, and only for fix loops. The nodes it re-runs measure new work, so their fix loops start afresh whoever rejected. Each rejection still counts against the gate's own reject loop, which only a person resets.
Why loops: ships empty
A loops: key that names no live loop does nothing and warns nobody. A stale
cap would look live and bind nothing, so the shipped policy.yaml names none.
The default: entry covers every fix loop. A loop's own max_attempts in the
chain wins over default:. The shipped fix loops therefore take their attempts
from the chain and only their wall clock from default:.
Caps are set per level
You set the four caps (time_cap_minutes, total_time_cap_minutes,
token_budget, budget_usd) per level of scope: the work item, its nodes
(a gate is a node), its steps and its tasks. Out of the box no level default is
set. Only the caps the shipped tasks set on themselves in library.yaml apply,
alongside the budget: dollar caps.
A value set lower down replaces the defaults for that scope and for every scope
under it that sets none. A node set to 240 minutes runs its steps and tasks
under 240 too. A default isn't a ceiling, and a narrower cap never exceeds a
broader one. A cap in a repository's policy: (in repos.yaml) or in the
chain's own policy: is a cap on the work item as a whole.
How a policy resolves
A work item freezes its policy when you file it. Layers run from the broadest source to the narrowest, and each may only tighten what it inherits. Your override is the one layer that changes after filing. A bad layer is refused at intake, so it fails when you file the item. See How the layers combine for the five layers, the inheritance rules and the error.
Time caps
There are two clocks.
time_cap_minutescounts running time. Paused time, external waits, gates and rate-limited time don't count.total_time_cap_minutescounts wall-clock time, including waits, gates and rate limits, less only a manual pause. For a task other than a wait, it is the task's running time. For a wait, it is the wait's timeout.
Every clock counts from the scope's start in the current run. A person's
retry starts them all afresh. A rate-limit relaunch or a stuck escalation's
own retry doesn't.
A node's clock is its own, independent of its fix loop's timeout_minutes,
which bounds only the fix cycles. A node's cap covers everything that runs as
that node: its tasks, recovery, fix loop, a gate's automated review, and the
automatic stuck-escalation turn. Your own escalation chat isn't the node
running, so it isn't capped.
A time cap is never treated as a code failure. It spends no recovery or fix-loop attempt, and no stuck escalation answers it. The item stops and waits for you: What a cap stop says gives the wording.
A work item's total_time_cap_minutes counts its gates and external waits, so
a cap of two days stops an item still waiting on a week-long approval. Size it
for the longest wait your chain allows.
Token and dollar budgets
A token or dollar cap refuses to start the next agent launch once its scope, or any scope around it, has reached its cap. Kraft checks before each launch, gate reviewers and escalation turns included. It can't interrupt a running agent, so overshoot is bounded by one launch's cost.
While an agent is still running, its spend counts too. Kraft prices the
agent's known tokens against a shipped rate table and shows the result as an
estimate (~$4.20 (est.)) until the session exits and the agent's own
reported figure replaces it. A long session's spend can therefore trip a
dollar cap before the session finishes.
Three things follow.
- A finished launch whose harness reported no cost counts at an estimate from the same rate table. If Kraft can't price it, the caps differ: see Harnesses that report no cost.
- Launches that start together in one scope, such as a parallel step's tasks, each pass the check before any of them has spent. A shared scope's cap can be overshot by up to their combined cost.
- A launch that resumes an earlier agent session counts only what it added.
budget.work_item_usd and budget.daily_usd in policy.yaml stay the outer
ceilings, above any per-scope budget_usd. For how Kraft estimates what a
harness spent, see Cost reporting.
The two dollar caps
An item has two dollar caps, and each has its own way up: see which stop offers what and raising a dollar cap from the command line.
The per-scope cap
budget_usd in the item's policy is a per-scope cap, like the time caps.
Item-wide it may exceed the chain's up to maxima.work_item. On a path it only
tightens, and an item-wide value replaces the level defaults on every scope the
chain set none on. A cap the chain set on a node, step or task still binds:
If the stop has no raise
says what to do.
The item's own dollar cap
The item's own dollar cap is the one kraft item create --budget sets in place
of budget.work_item_usd. No maxima bounds it. --usd none on raise-budget
lifts it.
Whichever of the two caps is lower stops the item first, and that is the one the
item's Budget shows. An item-wide budget_usd is listed under Changed for
this item, and while it is the lower cap, the pencil beside Budget changes
it rather than the item's own cap.
Why a raise is bounded
You can raise the cap that stopped an item for that one item, and retry it. The
raise is bounded so that an item can't pass the maxima you set for every item.
- An item's own cap may exceed the chain's, but only up to
maxima.work_item. - A cap on a node, step or task may pass its level's default, up to its level's maximum, and never what an enclosing scope allows.
- A limit set outside the item, such as
budget.daily_usd, isn't the item's to raise. - On spend a harness never reported, no higher number helps, because Kraft
still can't show the scope is under the new cap. Only lifting the dollar cap
with
--usd nonepasses it.
The steps are in
Raise a cap on a stopped item, and the
command's refusals are in kraft item raise-budget.
Why maxima start unset
A fresh install ships with defaults: and maxima: commented out. An
uncommented value is a real ceiling, and Kraft must not silently cap someone
who never chose a number.
A safety field listed only in maxima, such as allowed_tools, starts at its
maximum and can only be narrowed. That is why the reference example sets no
maxima.allowed_tools: a list there binds every agent task on every harness.
Not every harness can enforce a tool list. On claude, the harness every
shipped task uses, a list removes every built-in tool it doesn't name. Other
harnesses enforce it differently or refuse to launch under one. See
Permission gate for each harness, and
policy.yaml for the web tools codex and
cursor need in the list.
Related
- Then do it: Raise a cap on a stopped item.
- policy.yaml: every key and its default.
- Permission gate: how
allowed_toolsanddeny_toolsare enforced. - Vocabulary: what chain, node, step and task mean.