mirror of
https://github.com/hanzoai/mcp.git
synced 2026-11-03 01:31:11 +00:00
kai_next_action never returns a candidate whose preconditions are unmet, returns a single remaining one as is, and picks among several by BM25 against the goal, abstaining on a tie or no shared word; no Kai call (a Kai choice over candidates read below BM25 for tools). kai_recover maps each kai_log_triage class to a step (permission asks the user) and keeps the three-failure switch. kai_extract computes a yes/no field's confidence from P(true), abstains in Kai's unknown band (.35 to .65), and returns a score field's level rather than its mean. Recipes 02, 06, 07, 11, 12 and 14 check what the tools return, including abstention; the cookbook README and the tools' comments link the research runs instead of quoting numbers. bench/tools/post.py files each tool's read (benchmarks, one run an arm, items and cases as artifacts) to /v1/research.
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
/**
|
|
* Recipe 11: Test Assertion Failure Recovery
|
|
*
|
|
* Objective: Given a failed test assertion (e.g. left Err("1e3"), right Ok(1000.0)),
|
|
* evaluate available recovery actions to pick the most direct path to resolution.
|
|
*/
|
|
|
|
import { createRecipeClient, logRecipe, RecipeResult } from "./helper.js";
|
|
|
|
export async function runRecipe11(): Promise<RecipeResult> {
|
|
const client = await createRecipeClient();
|
|
|
|
const failureSnippet = "assertion failed: `(left == right)`\n left: `Err(\"1e3\")`,\n right: `Ok(1000.0)`\nat parser/src/number.rs:88:9";
|
|
|
|
const res = await client.callTool("kai_recover", {
|
|
error_category: "test",
|
|
failure_fingerprint: {
|
|
tool: "Bash",
|
|
error_snippet: failureSnippet,
|
|
attempt_count: 1,
|
|
last_action: "cargo test -p parser"
|
|
}
|
|
});
|
|
|
|
const result: RecipeResult = {
|
|
recipe: "11: Test Failure Recovery",
|
|
tool: "kai_recover",
|
|
success: !res.isError && res.data.strategy === "run_focused_test_diagnostics",
|
|
latency_ms: res.latency_ms,
|
|
output: res.data,
|
|
explanation: "A test failure reruns only the failing test, verbose, before any edit. No model call."
|
|
};
|
|
|
|
return result;
|
|
}
|
|
|
|
if (process.argv[1]?.endsWith("11-test-failure-recovery.ts")) {
|
|
runRecipe11().then(logRecipe).catch(console.error);
|
|
}
|