How a work item runs
A work item is one unit of work that ends in one merge request. Kraft runs it through a chain: an ordered list of nodes, where exec nodes run agents and commands and gate nodes stop until you approve or reject. When a node fails or a limit is hit, Kraft retries within bounds, and otherwise hands the item to you.
This page follows an item from filing to archive, in the words defined in Vocabulary. The statuses it holds on the way are on Work item statuses. To do it, see File a work item and Reviewing a change.
From filing to archive
In order:
- Filing. You file an item from the web UI,
kraft item create, or an agent over MCP. A trigger files one too, and so does auto-intake, which picks up ready issues from beads when you turn it on. - Intake. Kraft checks the item, then freezes its chain and policy and copies any attached spec or plan. A later edit to a chain file changes nothing for this item. See Intake.
- Paused. A filed item waits, paused, until you start it. Nothing has run and nothing has been spent.
- Start.
kraft item resume(Start in the board's side panel) claims the item and cuts its worktree. See Starting an item. - The chain. Kraft walks the nodes in order: an exec node runs its tasks and a gate node stops the item until you decide. See The shipped chains, Inside a node, Chain revision and Steering.
- Landing. The chain's last nodes mark the merge request ready, wait for an approving review if the forge requires one, merge it and wait for the post-merge pipeline.
- Completed. When the last node finishes, the item is
completedand Kraft closes the issues it implements in beads. - Archived. Archiving removes the worktree and the branch and takes the item off the board. See Archiving.
Starting an item
A filed item is paused. --autostart starts it at once, with two exceptions: a
session Kraft started is refused it, and the MCP tools file only paused items.
A trigger that files an item is held to the same rule. See
Use Kraft from your agent. Auto-intake starts
what it files, but only on a chain with at least one gate. The flags of
kraft item create are in Filing a work item.
Before the first node runs, Kraft:
- cuts a git worktree for the item from its base branch, on its own branch;
- copies the attached documents in; and
- runs the repo's
setup_command.
An in-place item skips the worktree and the
setup_command: it runs in the repo's own checkout, on its own branch cut from
the base branch, and its documents are committed there.
If a linked bead is still blocked by another bead, the item goes back to paused instead.
A workspace item's members are cut the same way, each as a worktree of its own connected repository, on a branch of the same name.
Inside a node
- chainordered nodes, frozen onto the item at intake
- holds: exec node
- holds: gate node
- gate node[waits for a person]
- exec node
- runs, in order: steps
- steps
- each holds, in parallel: tasks
- tasksagent, subprocess, builtin, forge
- each run is a: worker session
- worker sessionits status, log, result file and usage
- a task fails
- on_failure: recovery
- no recovery: sometimes fix loop
- recoveryrepair steps, once per entry into the node, then the node runs again
- passes: next node
- still failing: fix loop
- fix looprepair, then measure the node again; a judge from the second attempt; bounded by attempts and wall clock
- passes: next node
- cap reached, or the judge stops: escalation
- escalationa task that runs once the node is stuck
- retry, a fresh entry: steps
- cannot help: needs_human
- needs_human[waits for you]
- next node
A chain is a list of nodes. A gate node waits for you. An exec node
runs steps in order, and the tasks in one step in parallel. Each run of
a task is a worker session: a row with its status, log, result file,
tokens and cost. An agent or subprocess task launches a process for it. A
builtin or forge task runs inside Kraft. kraft view logs reads a session's
log.
When a task fails, a node can try three things, in this order. Each is optional, and each is declared on the node in its chain file (see Chain file keys).
| Recovery option | What it runs | It ends when |
|---|---|---|
Recovery (on_failure) | Repair steps, once per entry into the node, then the whole node again. It is for a problem outside the code, such as a label to fix on the merge request. | The repair steps finish and the node runs again. |
Fix loop (fix_loop) | A repair agent, then the whole node again from its first step. From the second attempt on, a judge agent decides whether the attempts are still converging. | The node passes, the loop reaches its attempt limit or its wall clock, or the judge stops it. |
Escalation (escalation) | A task that runs once the node is stuck. | If it succeeds, the node gets a fresh entry from its first step. If it doesn't, the item stops and waits for you. |
See Fix loop and judge for the loop's keys.
Some stops skip all three and go straight to you: a config error, a budget or
time cap, an infrastructure failure, a wait timeout and an agent's question.
No repair task can fix those. A rate limit doesn't stop and wait for you at
all. It parks the item as rate_limited.
Escalation turns
A node with no escalation of its own gets a generic one instead. When it
stops stuck, and auto_escalate_stuck is on in policy.yaml (the default),
Kraft starts an escalation turn.
It answers only stuck stops, never the ones listed above, and at most
auto_escalate_stuck_cap times. You can also start or continue one yourself
with kraft item escalate. The
Security page lists what an escalation
turn is allowed to do.
On a merge node that declares
on_merge_rejected, such as the
default chain's merge, a commit an escalation makes is never merged in
place: the item goes back to the node's restart_from and through
final_review first.
Only reviewed code merges
Added in 2.3
Approving final_review records the exact code you were shown: the approval
names the head you reviewed, and is refused if the branch has moved since.
When merge runs, it tells the forge to merge only that code, or the same code
rebased onto the base branch by Kraft with no conflict to resolve. Anything
else on the branch, whoever committed it, or a commit that reaches the merge
request on the forge, stops the item before it merges, with final_review
reopened, so the change comes back to you first. See
What the final review approves.
Kraft enforces gates in code. A sandboxed worker under a network: policy can't
decide its own gates. An unsandboxed worker runs as you, and can. A fresh install
sets no sandbox. Agents and gates
gives the full scope, and Default posture
what a fresh install does.
The shipped chains
Kraft ships two chains: default, the full process, and quick-task, the
smallest. The shipped chains lists the
nineteen nodes of default, which of them are gates and what each does, and the
two nodes of quick-task.
Chain revision
A chain is picked before its spec and plan exist. Once the plan is approved,
the chain_revision node has an agent read both against the nodes still to run
and propose changes. It may skip a node, add one built from library components,
yours, an installed add-on's or the item's own repository's repo library, or
adjust a task's model or effort, or an operational limit, within the
maxima in policy.yaml.
Only nodes after its gate may change. A gate never does. Nodes that open, describe, sync, ready or merge the merge request, or wait on its checks, can't be skipped.
Usually it proposes nothing, and the chain_revision_approval gate passes
without asking anyone. When it does propose something, the gate shows the
rationale, each change with the line of the spec or plan behind it, the
component each added node comes from, and the diff.
Approving replaces the item's chain with exactly the revision you were shown.
Kraft ties your approval to what you read: if the revision changed since, it
refuses the approval until you look again. A proposal that wouldn't validate
can't be approved. Reject it back to chain_revision instead.
The --digest flag of kraft item approve pins an
approval to the revision you read.
Slices
Added in 2.6
A large plan can be built by several agents at once. A ## Slices section in
the plan names the parts, each of which stands on its own with its own tests and
verification loop. Kraft files one child item per slice, each in its own
worktree and branch, then replays the children's commits onto the parent's
branch and runs verification, review and the merge request once, on the
combined code.
Slicing pays only when each part is that independent, because every slice has a worktree, setup, implementer and review of its own. To split a plan, see Split work into slices.
Steering
A steer reaches only the next agent Kraft launches. There is no channel into an agent that is already running, so a steer never reaches one. To redirect running work, pause it and resume it with a steer.
You give a steer in four ways:
kraft item resume ID --steer "..."reaches every paused agent task.--steer-task PATH=TEXTaddresses one task by its canonical path.kraft item retry ID --steer "..."goes into the prompt of the retried node.- Rejecting a gate with
--notesends the note, as a steer, to the node the gate sends the item back to. - Answering an agent's question:
kraft item resume ID --steer "..."on an item that stopped with one.
Kraft refuses a steer that no agent task would read, for example on a node that only runs a subprocess or waits on CI. It tells you so rather than dropping the text.
Review threads are the other way to give feedback. They carry line-level comments and stay until resolved. See Reviewing a change.
Archiving
Archiving removes the item's worktree and branch and takes it off the board. The record of what happened stays.
- You archive by hand, or set
archive.after_daysinpolicy.yamlto archive ended items automatically. The shipped file sets 30, and deleting the key turns it off. - A branch with commits that are nowhere else, such as a cancelled item's unpushed work, is kept.
- For a workspace item, archiving removes each member's worktree and branch from its connected repository too, with the same rule for each branch.
Related
- Then do it: File a work item, then review it at a gate.
- Work item statuses: the nine statuses, the moves between them, and what the board shows.
- Caps and budgets: the limits behind the stops that wait for you.
- Chain file keys: the keys that declare steps, recovery, fix loops and escalation.
- Architecture: the process and modules that do all of this.