fix(reply): a tool call written in Qwen's XML keeps its argument types

Every <parameter> value was passed as text, so a delete confirmed with
confirm=true reached chatChannels as "true" and asked again. Values now take
the type the tool's input schema declares (boolean, integer, number, array,
object); a value that does not fit stays text. The roadmap's eval summary now
names the reply-length failure apart from the later passing runs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-12 13:21:45 +09:00
parent 6d435caef0
commit 07c701be54
3 changed files with 50 additions and 5 deletions

View File

@@ -313,5 +313,22 @@ class TestToolCallBlockAsText:
name, args, _ = _extract('<tool_call>\n{"name": "webSearch", "arguments": {"search_query": "x"}}\n</tool_call>')
assert name == "webSearch" and args == {"search_query": "x"}
def test_qwen_xml_arguments_get_the_types_the_tool_declares(self):
"""A delete confirmed in XML must reach the tool as the boolean True, or it asks again."""
import jarvis.reply.engine as engine_mod
content = ("<tool_call>\n<function=chatChannels>\n<parameter=action>\ndelete\n</parameter>\n"
"<parameter=confirm>\ntrue\n</parameter>\n<parameter=limit>\n5\n</parameter>\n"
"</function>\n</tool_call>")
name, args, _ = engine_mod._extract_text_tool_call(content, {"chatChannels"})
assert name == "chatChannels"
assert args == {"action": "delete", "confirm": True, "limit": 5}
def test_qwen_xml_values_that_do_not_fit_their_type_stay_text(self):
import jarvis.reply.engine as engine_mod
content = ("<tool_call><function=chatChannels><parameter=confirm>maybe</parameter>"
"<parameter=limit>a few</parameter></function></tool_call>")
_, args, _ = engine_mod._extract_text_tool_call(content, {"chatChannels"})
assert args == {"confirm": "maybe", "limit": "a few"}
def test_prose_mentioning_tags_is_not_a_call(self):
assert _extract("I would call <tool_call> if I could.")[0] is None