[ROCm][CI] Restore Mistral tool-parser compatibility after unification (#50515)

Signed-off-by: Andreas Karatzas <Andreas.Karatzas@amd.com>

Andreas Karatzas committed Jul 31, 2026 at 11:32 UTC 8d8a4e0f2b118dc975bbba930aeb7c6cbd623c2a
2 files changed +21 -4
vllm/parser/mistral.py
+11 -4
@@ -526,14 +526,21 @@ class MistralParser(ParserEngine):
526 def _legacy_extract_tool_calls(
527 self,
528 model_output: str,
529 - request: ChatCompletionRequest,
529 + request: ChatCompletionRequest | None,
530 ) -> ExtractedToolCallInformation:
531 """Pre-v11 non-streaming extraction.
532
533 Handles ``[TOOL_CALLS][{...}]`` and guided bare-array formats.
534 """
535 + if request is None:
536 + tool_choice = None
537 + tools = None
538 + else:
539 + tool_choice = request.tool_choice
540 + tools = request.tools
541 +
542 # tool_choice="none" with tools: never produce tool calls.
536 - if request.tool_choice == "none" and request.tools:
543 + if tool_choice == "none" and tools:
544 return ExtractedToolCallInformation(
545 tools_called=False, tool_calls=[], content=model_output
546 )
@@ -550,8 +557,8 @@ class MistralParser(ParserEngine):
557 f"but got {model_output}."
558 )
559 stringified_tool_calls = raw_tool_calls[0].strip()
553 - elif request.tool_choice == "required" or isinstance(
554 - request.tool_choice, ChatCompletionNamedToolChoiceParam
560 + elif tool_choice == "required" or isinstance(
561 + tool_choice, ChatCompletionNamedToolChoiceParam
562 ):
563 # Guided bare-array output (no [TOOL_CALLS] marker).
564 stringified_tool_calls = model_output.strip()
vllm/tool_parsers/mistral_tool_parser.py
+10
@@ -25,6 +25,16 @@ class MistralToolParser(MistralParserToolAdapter): # type: ignore[valid-type, m
25 # correctly instead of crashing or dumping the raw envelope into arguments.
26 supports_required_and_named = False
27
28 + @property
29 + def bot_token(self) -> str:
30 + """Return the Mistral tool-call marker exposed by the legacy parser."""
31 + return self._parser_engine.bot_token
32 +
33 + @property
34 + def bot_token_id(self) -> int | None:
35 + """Return the token id for :attr:`bot_token`."""
36 + return self._parser_engine.bot_token_id
37 +
38 def adjust_request(
39 self,
40 request: ChatCompletionRequest | ResponsesRequest,