fix(reply): stop models answering past an available tool
M0 on Strata caught both v2 models skipping a tool they had been given: the recommended model made up "24 degrees, sunny" instead of calling the weather tool, and the fast model said "timer set" without calling the timer tool (3 of 3 each). qwen2.5:7b does the same through the engine. - Prompt: TOOL_HONESTY_RULES in the persona (live facts only from a tool result this turn, actions only claimed after a tool reports success, no answer text next to a tool call), restated at the end of the system message by tool_honesty_reminder() with the turn's real tool names. - Engine: skipped-tool guard. When a native-tool model answers before any tool has run and the plan names a callable tool as a concrete call, the answer is dropped and the plan steps are direct-executed, then the model answers from the results. Only literal, schema-valid steps run (regex fast path, no LLM repair); otherwise the held-back answer is delivered. - Planner: the AVAILABLE TOOLS lines now carry argument names (planner_tool_catalog), so concrete steps use the tool's real keys. - Eval evals/test_tool_skip_confabulation.py; on qwen2.5:7b, 3 runs each, available-tool cases went from 0/12 to 9/12 calling the tool. - M0 kit: tools_fast / tools_recommended stages (run_m0_tools.bat) rerun tool calling before and after the fix on the real models, loading the production system_prompt.py and planner.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -4,6 +4,7 @@ Options (--opt key=value):
|
||||
model=fast|recommended which preset to measure (default fast)
|
||||
url=http://.../v1 measure an already running server instead (no Strata management)
|
||||
context=32768 context size to start Strata with
|
||||
only=tools only re-measure tool calling, before and after the Jarvis fix
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -19,7 +20,9 @@ from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
|
||||
from m0lib.common import IS_WINDOWS, GpuSampler, StageResult, run_logged, say, scrub, stage_args # noqa: E402
|
||||
from m0lib.llm_bench import bench_single, test_decode, test_images, test_parallel, test_vram_shrink, warmup # noqa: E402
|
||||
from m0lib.llm_bench import (bench_single, test_decode, test_images, test_parallel, test_tools, # noqa: E402
|
||||
test_vram_shrink, warmup)
|
||||
from m0lib.tool_fix import test_tools_fixed # noqa: E402
|
||||
from m0lib.llm_client import ChatClient, http_json # noqa: E402
|
||||
|
||||
PRESETS = {
|
||||
@@ -190,16 +193,29 @@ def server_info(base: str) -> dict:
|
||||
return info
|
||||
|
||||
|
||||
def measure_external(r: StageResult, url: str, context: int) -> None:
|
||||
def tools_only(r: StageResult, c: ChatClient) -> None:
|
||||
"""Tool calling as first measured (baseline) and with the Jarvis fix."""
|
||||
for fn in (lambda: warmup(r, c), lambda: test_tools(r, c), lambda: test_tools_fixed(r, c)):
|
||||
try:
|
||||
fn()
|
||||
except Exception as e:
|
||||
r.error("tools", e)
|
||||
r.save()
|
||||
|
||||
|
||||
def measure_external(r: StageResult, url: str, context: int, only: str = "") -> None:
|
||||
c = ChatClient(url)
|
||||
r["server"] = {"url": url, "model": c.model, "info": server_info(c.base)}
|
||||
if only == "tools":
|
||||
tools_only(r, c)
|
||||
return
|
||||
with GpuSampler() as g:
|
||||
bench_single(r, c, context)
|
||||
test_parallel(r, c)
|
||||
r["gpu"] = g.summary()
|
||||
|
||||
|
||||
def measure_strata(r: StageResult, work: Path, which: str, context: int) -> None:
|
||||
def measure_strata(r: StageResult, work: Path, which: str, context: int, only: str = "") -> None:
|
||||
preset = PRESETS[which]
|
||||
r["preset"] = dict(preset, key=which, context=context)
|
||||
s = Strata(work, work / "logs" / f"strata_{which}.log")
|
||||
@@ -227,6 +243,10 @@ def measure_strata(r: StageResult, work: Path, which: str, context: int) -> None
|
||||
base = f"http://127.0.0.1:{PORT}/v1"
|
||||
c = ChatClient(base)
|
||||
r["server"] = {"model": c.model, "info": server_info(base), "status": s.status()}
|
||||
if only == "tools":
|
||||
tools_only(r, c)
|
||||
s.stop()
|
||||
return
|
||||
with GpuSampler() as g:
|
||||
bench_single(r, c, context)
|
||||
r["gpu_single"] = g.summary()
|
||||
@@ -260,12 +280,13 @@ def main() -> int:
|
||||
out, work, opts = stage_args()
|
||||
which = opts.get("model", "fast")
|
||||
context = int(opts.get("context", "32768"))
|
||||
r = StageResult(f"llm_{which}", out)
|
||||
only = opts.get("only", "")
|
||||
r = StageResult(f"{'tools' if only == 'tools' else 'llm'}_{which}", out)
|
||||
try:
|
||||
if opts.get("url"):
|
||||
measure_external(r, opts["url"], context)
|
||||
measure_external(r, opts["url"], context, only)
|
||||
else:
|
||||
measure_strata(r, work, which, context)
|
||||
measure_strata(r, work, which, context, only)
|
||||
except Exception as e:
|
||||
r.error("llm", e)
|
||||
# No server reached means nothing was measured: "failed" so the next run retries it.
|
||||
|
||||
Reference in New Issue
Block a user