For AI agents and LLMs: a machine-readable index is available at llms.txt. A plain-Markdown version of any documentation page is available by appending .md to its URL.
Skip to main content

Agent Mode

Agent Mode outputs structured NDJSON instead of the interactive terminal UI. It's how AI coding agents (Claude Code, Codex CLI, Gemini CLI) consume Kane CLI results: parse events programmatically, extract the final result, and present it to the user.

Enable Agent Mode​

Add --agent to any run command:

Verified
kane-cli run "Verify the checkout flow completes successfully" \
--url https://myapp.com \
--agent \
--headless

When --agent is active:

  • The interactive TUI is fully suppressed (no boot screen, no menus)
  • Stdin is not used (no interactive prompts)
tip

Always combine --agent with --headless in non-interactive environments (CI/CD, agent contexts) to avoid display server errors.


Output Format​

Kane CLI outputs one JSON object per line (NDJSON) to stdout:

Verified
{"type":"run_start","objective":"Verify checkout","timestamp":"2026-04-14T10:30:45Z"}
{"type":"step_start","index":0,"objective":"Navigate to cart page"}
{"type":"step_event","index":0,"event":"action","detail":"Navigated to /cart","success":true}
{"type":"step_event","index":0,"event":"screenshot","detail":"Screenshot captured"}
{"type":"step_end","index":0,"status":"passed","duration":2.3,"summary":"Navigated to cart"}
{"type":"step_start","index":1,"objective":"Click checkout button"}
...
{"type":"run_end","status":"passed","summary":"...","duration":45.2,...}

Event Schema​

Step Events​

TypeKey FieldsDescription
step_startindex, objective, child_id*Step began
step_eventindex, event**, detail, success*Activity within a step
step_endindex, status (passed|failed), duration, summaryStep completed

*optional
**event values: screenshot, reasoning, action, vision, assertion, evaluation

Flow Events​

TypeKey FieldsDescription
run_startobjective, timestampRun started
bifurcationflows[], countAgent branched into sub-flows
child_agent_startchild_id, objective, parent_stepChild agent spawned
child_agent_endchild_id, success, steps_taken, summaryChild agent finished
ask_userquestion, step_index, options*Agent needs input (auto-disabled when stdin is not TTY)
errormessageError occurred
run_end(see below)Terminal event: always the last line

The run_end Event​

run_end is always the last line of a run that started (see Exit Codes for runs refused before they start). It contains the complete test result:

Verified
{
"type": "run_end",
"status": "passed",
"summary": "Searched for laptop and added first result to cart",
"one_liner": "Searched for laptop on Amazon and added to cart",
"reason": "Objective completed",
"duration": 45.2,
"final_state": {
"price": "$29.99",
"product_name": "Wireless Headphones"
},
"context": {
"memory": {},
"variables": {},
"pointer": "(passed) Searched for laptop on Amazon"
},
"token_usage": {
"reasoning_input": 12000,
"reasoning_output": 800,
"vision_input": 5000,
"vision_output": 200
},
"session_dir": "~/.testmuai/kaneai/sessions/2026-04-14_10-30-45_a1b2c3",
"run_dir": "~/.testmuai/kaneai/sessions/2026-04-14_10-30-45_a1b2c3/runs/0",
"test_url": "https://test-manager.lambdatest.com/projects/123/test-cases/456"
}

Key Fields​

FieldDescription
status"passed" or "failed"
summaryFull description of what the agent did
one_linerShort single-sentence summary
reasonWhy the run stopped (present on failure)
final_stateValues extracted via "store as" objectives
test_urlLink to the TestMu AI dashboard for this run
session_dirPath to session-level logs
run_dirPath to run-level logs, step JSON, screenshots
token_usageToken consumption breakdown

The .evidence proof pack​

Every Kane CLI run produces an .evidence pack stored natively in the results folder, so failure context travels with the run instead of living in a separate dashboard. Each pack contains the full execution proof for the run: step-by-step traces, screenshots, video, and command, network and console logs, plus the NDJSON event stream and result codes. Coding agents and humans read the same evidence to see exactly what happened, where it failed, and why.


Parsing Output​

Get the run_end event:

Verified
# Get just the final result
kane-cli run "..." --agent 2>/dev/null | tail -1 | jq .

# Extract status
kane-cli run "..." --agent 2>/dev/null | tail -1 | jq -r '.status'

# Extract a stored value
kane-cli run "go to example.com, store the price as 'price'" --agent 2>/dev/null \
| tail -1 | jq -r '.final_state.price'

Exit Codes​

Check the exit code before you parse stdout. A run refused before it starts can exit 2 with no run_end line, so reading only the last line can miss the failure.

kane-cli run "..." --agent --headless > run.ndjson; echo "exit=$?"

Exit codes for kane-cli run and kane-cli testmd run:

CodeMeaning
0Passed.
1Failed: the objective ran but did not pass (for testmd run, a non-optional step failed), or the results upload failed. An unreachable start URL also exits 1, after about 45 seconds, and the run spends credits (observed 2026-11-19).
2Error: sign-in or auth failure, configuration, no start URL, a Chrome launch failure or crash, an unknown subcommand, or another infrastructure issue. A run refused before it starts has no run_end line.
3Timeout or cancelled.

Other commands keep the same numbers with different meanings:

Command0123
kane-cli testrun runAll members passedAt least one member failed or brokeUsage error, invalid plan (preflight failures) or auth error; nothing ranCancelled; there is no suite timeout
Assurance commands with --mode agentCompleteRuntime failureUsage, auth or refusal; nothing was mutated, with the exceptions listed in AutomationPaused and resumable within 24 hours, not a timeout; for context push, context pull and a stopped rebase, a person has to decide something

The assurance commands take --mode agent, not --agent, and their stream ends with a done event instead of run_end. See testrun and Automation for the full rules.


Handling ask_user Events​

If an objective requires user input mid-run, Kane CLI fires ask_user:

Verified
{"type": "ask_user", "question": "Which item should I select?", "options": ["Small", "Medium", "Large"]}
note

ask_user is auto-disabled when stdin is not a TTY. In CI/CD and AI agent contexts, stdin is never a TTY, so ask_user never fires. Write objectives that don't require interactive prompts.

If stdin IS a TTY, respond by writing JSON to stdin:

Verified
{"type": "user_response", "answer": "Medium"}

To cancel:

Verified
{"type": "cancel"}

Agent Mode vs Interactive Mode​

Agent Mode (--agent)Interactive Mode
TUISuppressedFull terminal UI
OutputNDJSON to stdoutFormatted text
StderrLogs onlyLogs + progress UI
Use caseAI agents, programmatic toolsHuman development

Next Steps​

  • Error Codes: Complete reference of result_code values and recommended actions
  • Parallel Execution: Run multiple tests concurrently
  • Skills: Install the Kane CLI skill for Claude, Codex, or Gemini
  • CLI Reference: Full flag and command reference

Terminal First Testing With Kane CLI

Natural language browser & mobile app tests right from terminal.

×
Schedule Your Personal Demo
Kane CLI terminal

Help and Support

Related Articles