Plans
A plan is a durable artifact for multi-step work: the model drafts it, you edit and approve it, and ka agent executes it against a shell command that decides what done means. One store row per plan (schema v18), owned by its user, so it survives session rotation.
Lifecycle
Section titled “Lifecycle”drafting → draft → approved → executing → done | failed | abandoned; /plan set pulls any settled status back to draft. Illegal transitions are refused by the store.
| Command | Effect |
|---|---|
/plan draft <goal> |
Submits a drafting turn (source plan:<id>); the answer becomes the body, and a Verify: line in it is lifted into the plan’s verify command. The empty-answer nudge’s re-ask appends; a still-empty cycle stays drafting. |
/plan list · /plan show <id> |
Your plans (id, status, repairs, title); show renders the body and the verify command, unarmed until approve. |
/plan set <id> <markdown> |
Rewrite the body; un-settles any settled status back to draft. |
/plan approve <id> |
Operator-only (admin role). Approval arms the gate: it consents to exactly the Verify: string. |
/plan run <id> |
approved → executing: submits the run turn. |
/plan stop <id> |
abandoned, and the queued repair (if any) is dropped. |
The model edits a plan body only through the kagent__plan_update bridge tool, which refuses approved rows and other users’ rows: an approved plan is immutable to the model, and /plan set is the only path that un-approves.
The verify gate
Section titled “The verify gate”When a plan:<id> turn on an executing plan finishes clean (an error, aborted or interrupted stop runs no gate and auto-submits nothing; an empty answer is still gate-eligible):
- No
Verify:line: the plan settlesdoneon the clean turn. - A
Verify:command: it runs through the same zero-token gate crons use (sh -c, the session workspace, a 30 s kill, a 4 KiB output cap;spawn_blocking, so the daemon never blocks). Exit 0 settlesdonewith a notice. A failure enqueues exactly one repair turn (the plan body plus the gate output inside the<gate-output>envelope) whileiterations < max_iterations(default 3), then settlesfailed. - Every gate execution appends a
plan.verifyaudit row (outcome, repair count, exit code). The gate runs as the daemon, like a cron gate; the intents rule stays scoped to external writes.
The verify cycle is daemon-side: turn-loop hooks and same-turn failure re-feed live below the ka-port boundary (ka-harness handoffs), and the iteration cap is the only automatic bound.
Budget, stop, restart
Section titled “Budget, stop, restart”- A budget-exceeded window defers the repair: the plan stays
executingand you re-run/plan run(or wait for the window to roll);iterationsis durable. - Boot finding an
executingplan with an empty queue resumes nothing;/plan runon anexecutingplan re-submits in place, which is the documented recovery after a restart. - An
executingplan’s empty answer belongs to the verify gate: the empty-answer nudge stands down, so the failure is never double-fed. /plan stopabandons the plan and removes the pending repair from the queue.