[Bugfix][Responses API] Fix streaming tool calls on /v1/responses (#39892)
Signed-off-by: Hoang Nguyen <118159510+hnt2601@users.noreply.github.com> Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -360,12 +360,13 @@ class Gemma4ToolParser(ToolParser):
|
||||
self, request: ChatCompletionRequest | ResponsesRequest
|
||||
) -> ChatCompletionRequest | ResponsesRequest:
|
||||
request = super().adjust_request(request)
|
||||
if (
|
||||
isinstance(request, ChatCompletionRequest)
|
||||
and request.tools
|
||||
and request.tool_choice != "none"
|
||||
):
|
||||
# Don't skip special tokens — <|tool_call> etc. are needed
|
||||
if request.tools and request.tool_choice != "none":
|
||||
# Don't skip special tokens — <|tool_call> etc. are needed for
|
||||
# the parser to detect tool calls. Apply to BOTH
|
||||
# ChatCompletionRequest and ResponsesRequest (the previous
|
||||
# isinstance(ChatCompletionRequest) guard caused tool-call
|
||||
# delimiters to be stripped on /v1/responses, leaking raw
|
||||
# `call:fn{...}` text via output_text.delta).
|
||||
request.skip_special_tokens = False
|
||||
return request
|
||||
|
||||
|
||||
Reference in New Issue
Block a user