okami.mom/strata
git clone https://git.nkp.pet/okami.mom/strata
ef8071303
main
1"""serve/test_tool_name_space.py - a tool call written `<function= NAME>` (a space after the `=`) is the call NAME. 2 3Seen live (Qwen3.8-Flash-Next IQ2_XS, Zed's agent panel): the model wrote `<function= capture>` inside its thinking; 4the name was read as " capture", matched no declared tool, stayed reasoning text (#804), and the turn ended with no 5call, so the agent stopped. After the thinking the same call came out named " capture", and its arguments were 6typed without the tool's schema. 7 8python -m unittest serve.test_tool_name_space -v 9""" 10import sys 11import unittest 12from pathlib import Path 13 14sys .path .insert (0 ,str (Path (__file__ ).resolve ().parents [1 ])) 15 16from serve .frontend import OutputParser # noqa: E402 17 18# "42" for a string parameter stays a string only when the call finds its tool's schema 19SCHEMA = [{"name" :"capture" ,"parameters" : {"properties" : {"content" : {"type" :"string" }}}}] 20CALL = "<tool_call>\n<function= capture>\n<parameter=content>\n42\n</parameter>\n</function>\n</tool_call>" 21 22 23def calls (text ,stream_tools ): 24p = OutputParser (thinking = True ,tools = SCHEMA ,stream_tools = stream_tools ) 25evs = [] 26for i in range (0 ,len (text ),3 ):# fed in small pieces, as a stream arrives 27evs += p .feed (text [i :i + 3 ]) 28evs += p .finish ("stop" ) 29return [(e .call .name ,e .call .arguments )for e in evs if e .kind == "tool_call" ] 30 31 32class SpacedName (unittest .TestCase ): 33def check (self ,text ): 34for stream_tools in (False ,True ): 35with self .subTest (stream_tools = stream_tools ): 36self .assertEqual (calls (text ,stream_tools ), [("capture" , {"content" :"42" })]) 37 38def test_inside_the_thinking (self ): 39self .check ("Let me save this.\n" + CALL + "\n" ) 40 41def test_after_the_thinking (self ): 42self .check ("Saving it.</think>\n\n" + CALL ) 43 44 45if __name__ == "__main__" : 46unittest .main ()