Skip to content

Headless (ka run)

ka run executes exactly one turn with no interface: built for scripts, CI, and piping.

Terminal window
ka run "summarize the build error"
echo "what does this repo do?" | ka run
ka run -c "continue: what else?" # continue the newest strand
ka run --session 3f9c "next step" # resume a specific session
--print Output
text (default) The final answer only
ndjson ka’s own event stream: literally the engine’s Event side, one JSON object per line
stream-json Claude-Code-compatible event shapes, for tooling that already speaks that dialect
--rpc RPC event protocol for programmatic hosts driving ka as a subprocess
Terminal window
ka run --print ndjson "list the failing tests" |
jq -c 'select(.type == "turn_finished") | .usage'
Flag Behavior
-o FILE Write the final answer to a file
--max-turns N Stop after N turns
--max-budget-usd Asks the model to stop once past the ceiling
--max-cost / --max-time Exit with code 3 when the cap is crossed
--warn-cost Warn on stderr when the session cost grows

Pass a JSON schema and the reply must satisfy it:

Terminal window
ka run --schema issue.schema.json "file the flaky test as JSON" > issue.json
Code Meaning
0 ok
1 error
2 aborted
3 cap crossed (--max-cost / --max-time)
42 input rejected (e.g. a --schema validation failure)

There is no human to ask, so asks resolve strictly: exec-tier calls that would prompt are denied (not auto-approved), and hardstops are denied outright. Pre-approve what a script needs with [[rules]] or [permissions] allow, or run with --mode allow deliberately. For CI, the explicit stance is --mode dont_ask (never block on a prompt) with [permissions] prompt_policy = "deny"; see automation.