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 Preflight
Before a coding agent starts a task, ask Kai what kind of task it is, which model tier it needs, and whether the request is missing information.
Request (request.json)
{
"model": "kai",
"state": {
"prompt": "Refactor the authentication middleware to support JWT RS256 signing and verify against external JWKS URL with 1-hour in-memory caching.",
"workspace_files_count": 142,
"git_dirty": false
},
"questions": {
"task_type": {
"type": "choice",
"instructions": "Classify the primary engineering activity",
"criteria": {
"bugfix": "fixing an existing error or regression",
"refactor": "restructuring existing code without changing public behavior",
"new_feature": "implementing new endpoints or capabilities",
"documentation": "writing or updating markdown/docs"
}
},
"model_tier": {
"type": "choice",
"instructions": "Select required model capability tier",
"criteria": {
"flash": "simple one-file changes or typo fixes",
"standard": "multi-file edits with standard conventions",
"ultra": "complex security, concurrency, or architectural refactor"
}
},
"requires_user_clarification": {
"type": "noul",
"instructions": "Are the requirements ambiguous or missing critical information?"
}
}
}
Checked answers (expect.json)
task_type(choice):new_featureorrefactormodel_tier(choice):ultrarequires_user_clarification(noul): not checked, no obvious answer on this input
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/01_agent_preflight/request.json
python3 recipes/01_agent_preflight/run.py
npx tsx recipes/01_agent_preflight/run.ts
run.py and run.ts print every answer and exit 1 when a checked answer is wrong.