Preserve OpenAI tool call additional properties#6365
Closed
ultramancode wants to merge 1 commit into
Closed
Conversation
Signed-off-by: Taewoong Kim <ktw2172@gmail.com>
7b3f30b to
9e71de2
Compare
Contributor
|
@ultramancode Please add a related integration test that fails when the fix is not present. |
Contributor
|
@ultramancode , can you point us to where the OpenAI API spec defines additionalProperties: https://developers.openai.com/api/reference/resources/chat/subresources/completions/methods/create ? |
Contributor
Author
|
I replied with more context in #6364. If this still seems like the right direction, I can add the requested integration test. |
tzolov
added a commit
that referenced
this pull request
Jun 10, 2026
Additional properties from each tool-call object are serialised to a JSON string (keyed by `tool_call_id`) and stored in `AssistantMessage` metadata. When the conversation is replayed, the properties are deserialised and restored via `putAllAdditionalProperties` on the SDK request builder. The fix is provider-neutral and covers both sync and streaming paths. Reference doc is updated and tests are added Fixes #6364 Signed-off-by: Taewoong Kim <ktw2172@gmail.com> Signed-off-by: Christian Tzolov <christian.tzolov@broadcom.com> Co-authored-by: Christian Tzolov <christian.tzolov@broadcom.com>
Contributor
|
Thanks @ultramancode , I've made some optimizations and merged it |
Contributor
|
rebased, optimized, squashed and merged at 798d433 |
Contributor
Author
|
Thanks for taking care of this! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #6364
OpenAiChatModelcurrently drops additional properties attached to assistant tool calls while converting OpenAI SDK responses into Spring AIAssistantMessage.ToolCalls.That breaks Gemini OpenAI-compatible tool-calling flows for models that require provider metadata such as:
to be sent back on the follow-up model call after tool execution. Without it, Gemini 3.x models can fail with:
The OpenAI Java SDK already keeps these provider fields in
_additionalProperties(). This PR carries the root tool-call additional properties throughAssistantMessagemetadata and restores them on the OpenAI SDK request object when conversation history is replayed.I also checked several Gemini OpenAI-compatible response shapes, including
gemini-2.5-flash-liteandgemini-3.5-flash, covering responses with and withoutthought_signature. When no additional properties are present, nothing extra is replayed.There is no Gemini-specific handling here.
Spring AI only replays additional fields that were already present in the provider response.