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:
@@ -197,3 +197,24 @@ class TestLoadAgentInstructions:
|
||||
f.write_text("x", encoding="utf-8")
|
||||
# Pointed at a file, not a directory → fail-open.
|
||||
assert load_agent_instructions(str(f)) == ""
|
||||
|
||||
|
||||
class TestToolHonestyRules:
|
||||
"""The persona carries the tool honesty rules (live facts and actions only
|
||||
from tool results) for every name and language lock."""
|
||||
|
||||
def test_rules_are_in_every_rendered_prompt(self):
|
||||
from jarvis.system_prompt import TOOL_HONESTY_RULES
|
||||
for prompt in (build_system_prompt("Jarvis"), build_system_prompt("Friday", "Korean")):
|
||||
assert TOOL_HONESTY_RULES in prompt
|
||||
|
||||
def test_reminder_names_the_turns_tools_but_not_the_sentinels(self):
|
||||
from jarvis.system_prompt import tool_honesty_reminder
|
||||
text = tool_honesty_reminder(["getWeather", "logMeal", "stop", "toolSearchTool"])
|
||||
assert "getWeather, logMeal." in text
|
||||
assert "stop" not in text.split("this turn:")[1].split(".")[0]
|
||||
assert "toolSearchTool" not in text
|
||||
|
||||
def test_reminder_without_tools_says_none(self):
|
||||
from jarvis.system_prompt import tool_honesty_reminder
|
||||
assert "Your tools this turn: none." in tool_honesty_reminder(["stop"])
|
||||
|
||||
Reference in New Issue
Block a user