[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:
Hoang Nguyen
2026-04-20 11:24:52 +08:00
committed by GitHub
co-authored by Claude
parent fcb31c1ac3
commit 6e10cb54f6
3 changed files with 137 additions and 13 deletions
+14 -7
View File
@@ -103,13 +103,20 @@ class ToolParser:
)
request.response_format = None
if isinstance(request, ResponsesRequest):
request.text = ResponseTextConfig()
request.text.format = ResponseFormatTextJSONSchemaConfig(
name="tool_calling_response",
schema=json_schema_from_tool,
type="json_schema",
description="Response format for tool calling",
strict=True,
# Single-shot construction so Pydantic v2 tracks `format`
# in __fields_set__ — assigning to `.format` after the bare
# `ResponseTextConfig()` constructor does not, which can
# drop the nested config from `model_dump`. Also drop the
# `description` kwarg: it is not a field on
# ResponseFormatTextJSONSchemaConfig and was being silently
# passed through as extra.
request.text = ResponseTextConfig(
format=ResponseFormatTextJSONSchemaConfig(
type="json_schema",
name="tool_calling_response",
schema=json_schema_from_tool,
strict=True,
)
)
return request