@@ -277,6 +277,33 @@ def test_handle_chat_completions_with_null_tool_content(self):
277277 self .assertIn ("id" , response_body )
278278 self .assertIn ("choices" , response_body )
279279
280+ def test_make_state_machine_empty_tool_call_end (self ):
281+ class FakeTokenizer :
282+ has_thinking = False
283+ has_tool_calling = True
284+ tool_call_start = "[TOOL_CALLS]"
285+ tool_call_end = ""
286+ tool_call_start_tokens = (100 ,)
287+ tool_call_end_tokens = ()
288+ eos_token_ids = [2 ]
289+
290+ def convert_ids_to_tokens (self , t ):
291+ return f"<eos{ t } >"
292+
293+ sm , _ = self .response_generator ._make_state_machine (
294+ ("fake-empty-end" , None , None ),
295+ FakeTokenizer (),
296+ stop_words = [],
297+ )
298+ state = sm .make_state ()
299+ state , _ , s = sm .match (state , 100 )
300+ self .assertEqual (s , "tool" )
301+ for tok in [42 , 43 , 44 ]:
302+ state , _ , s = sm .match (state , tok )
303+ self .assertEqual (s , "tool" )
304+ state , _ , s = sm .match (state , 2 )
305+ self .assertIsNone (s )
306+
280307 def test_handle_models (self ):
281308 url = f"http://localhost:{ self .port } /v1/models"
282309 response = requests .get (url )
0 commit comments