mirror of
https://github.com/hanzoai/kai.git
synced 2026-10-17 11:18:06 +00:00
Every runner printed whatever came back and exited 0, and fell back to a second raw HTTP call when the SDK import failed. Now each recipe carries expect.json, the answers a careful reader gives on its own input: a list of acceptable options for a choice, of level indices for a score, true or false for a noul. run.py and run.ts send request.json through the SDK, print every answer, and exit 1 when a checked one is wrong. A question with no obvious answer on its input is printed and not checked. Recipes 09 and 11 had no input with an obvious answer, so each state gains the one fact that decides it. The recipe READMEs describe what each recipe asks instead of capabilities it never exercised, and copy the request and checked answers from the two JSON files. Co-authored-by: Hanzo Dev <[email protected]>
Agent Command Risk Gate
Before an agent runs a shell command, ask Kai how destructive the command is and whether to allow it, ask a person, or deny it. Your own policy keeps the final say.
Request (request.json)
{
"model": "kai",
"state": {
"command": "docker system prune -a --volumes -f",
"environment": "staging",
"caller_role": "ci_agent"
},
"questions": {
"destruction_risk": {
"type": "score",
"instructions": "Assess command destructiveness",
"criteria": [
"0: read-only or inspection command",
"1: idempotent build or cache write",
"2: reversible container modification",
"3: broad, unconstrained data purge"
]
},
"verdict": {
"type": "choice",
"instructions": "Determine safety gate verdict",
"criteria": {
"allow": "safe to run unattended",
"ask": "halt and require explicit human confirmation",
"deny": "prohibited action, block immediately"
}
}
}
}
Checked answers (expect.json)
destruction_risk(score): most probable level 33: broad, unconstrained data purgeverdict(choice):askordeny
Run
From the repository root, after pip install -r requirements.txt and npm install:
curl -sS --fail-with-body https://api.hanzo.ai/v1/decisions \
-H "Authorization: Bearer $HANZO_API_KEY" \
-H "Content-Type: application/json" \
-d @recipes/03_agent_command_risk/request.json
python3 recipes/03_agent_command_risk/run.py
npx tsx recipes/03_agent_command_risk/run.ts
run.py and run.ts print every answer and exit 1 when a checked answer is wrong.