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:
@@ -788,3 +788,49 @@ class TestPlanHasUnresolvedToolSteps:
|
||||
assert plan_has_unresolved_tool_steps(
|
||||
plan, ["chrome-devtools__navigate_page"]
|
||||
) is False
|
||||
|
||||
|
||||
class TestNamedToolSteps:
|
||||
"""named_tool_steps picks plan steps that start with a callable tool name,
|
||||
whatever their position in the plan."""
|
||||
|
||||
def test_lone_tool_step_and_memory_prefixed_step_are_found(self):
|
||||
from jarvis.reply.planner import named_tool_steps
|
||||
assert named_tool_steps(["logMeal meal='banana'"], ["logMeal"]) == ["logMeal meal='banana'"]
|
||||
assert named_tool_steps(
|
||||
["searchMemory topic='home'", "getWeather", "Reply to the user."], ["getWeather"]
|
||||
) == ["getWeather"]
|
||||
|
||||
def test_prose_and_unknown_names_are_not_tool_steps(self):
|
||||
from jarvis.reply.planner import named_tool_steps
|
||||
assert named_tool_steps(["Reply to the user."], ["getWeather"]) == []
|
||||
assert named_tool_steps(["controlTimer duration=5", "Reply to the user."], ["getWeather"]) == []
|
||||
|
||||
|
||||
class TestParseConcreteToolStep:
|
||||
SCHEMA = [{"type": "function", "function": {"name": "logMeal", "parameters": {
|
||||
"type": "object", "properties": {"meal": {"type": "string"}}}}}]
|
||||
|
||||
def test_concrete_step_parses(self):
|
||||
from jarvis.reply.planner import parse_concrete_tool_step
|
||||
assert parse_concrete_tool_step("logMeal meal='banana'", self.SCHEMA) == ("logMeal", {"meal": "banana"})
|
||||
assert parse_concrete_tool_step("logMeal", self.SCHEMA) == ("logMeal", {})
|
||||
|
||||
def test_unknown_keys_prose_and_placeholders_do_not_parse(self):
|
||||
from jarvis.reply.planner import parse_concrete_tool_step
|
||||
assert parse_concrete_tool_step("logMeal food='banana'", self.SCHEMA) is None
|
||||
assert parse_concrete_tool_step("logMeal the banana I ate", self.SCHEMA) is None
|
||||
assert parse_concrete_tool_step("logMeal meal='<meal from step 1>'", self.SCHEMA) is None
|
||||
assert parse_concrete_tool_step("getWeather", self.SCHEMA) is None
|
||||
|
||||
|
||||
class TestPlannerToolCatalog:
|
||||
def test_descriptions_carry_the_argument_names(self):
|
||||
from jarvis.reply.planner import planner_tool_catalog
|
||||
schema = [
|
||||
{"type": "function", "function": {"name": "getWeather", "description": "Weather only.\nMore.",
|
||||
"parameters": {"type": "object", "properties": {"location": {"type": "string"}}}}},
|
||||
{"type": "function", "function": {"name": "stop", "description": "End.",
|
||||
"parameters": {"type": "object", "properties": {}}}},
|
||||
]
|
||||
assert planner_tool_catalog(schema) == [("getWeather", "Weather only. (args: location)"), ("stop", "End.")]
|
||||
|
||||
Reference in New Issue
Block a user