feat(m0): try the next model when tool calling still fails with the fix

User rule: if the tool-calling fix does not work, change the model. The
tools_fast / tools_recommended stages now measure the next, less
compressed model of the same family (fast: UD-Q6_K_XL then Q8_0;
recommended: IQ3_XXS then IQ3_S) when the default still gets a scored
case wrong, stop at the first one that passes every case, and record it
as tools_verdict.chosen. Candidates without enough free disk are skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-10 15:09:58 +09:00
parent 903e0eb9de
commit 85a562c171
5 changed files with 118 additions and 12 deletions

View File

@@ -306,3 +306,37 @@ def test_model_that_calls_the_tool_is_scored_without_the_guard():
assert row["model_ok"] is True and row["guard_ran"] is False and row["ok"] is True
assert row["text_with_call"] is False
# ---------------------------------------------------------------------------
# "If the fix does not work, change the model": the tools stage tries the
# next model of the same family until one passes every scored case.
def _summary(ok, total=21):
return {"ok": ok, "model_ok": ok, "total": total, "guard_ran": 0, "text_with_call": 0}
def test_passing_default_tries_no_other_model(tmp_path):
r = common.StageResult("tools_fast", tmp_path / "r.json")
tried = []
llm.try_candidates(r, "fast", _summary(21), lambda p: tried.append(p) or _summary(21), free_gb=lambda: 999)
assert tried == [] and r["tools_verdict"]["chosen"] == llm.PRESETS["fast"]["label"]
def test_failing_default_stops_at_the_first_candidate_that_passes(tmp_path):
r = common.StageResult("tools_fast", tmp_path / "r.json")
results = iter([_summary(20), _summary(21)])
tried = []
llm.try_candidates(r, "fast", _summary(18), lambda p: tried.append(p["model"]) or next(results),
free_gb=lambda: 999)
assert tried == [c["model"] for c in llm.CANDIDATES["fast"][:2]]
assert r["tools_verdict"]["chosen"] == llm.CANDIDATES["fast"][1]["label"]
def test_candidate_without_disk_space_is_skipped_not_downloaded(tmp_path):
r = common.StageResult("tools_recommended", tmp_path / "r.json")
tried = []
llm.try_candidates(r, "recommended", _summary(18), lambda p: tried.append(p) or _summary(21), free_gb=lambda: 1)
assert tried == []
assert r["tools_verdict"]["chosen"] is None
assert all(c["skipped"] == "disk" for c in r["tools_verdict"]["candidates"])