Fix JsonSchemaGenerator for method input parameters#4524
Merged
markpollack merged 1 commit intospring-projects:mainfrom Oct 1, 2025
Merged
Conversation
- For method input parameters, if the JSON schema generator adds OpenAPI "format" property, some LLMs (ex: Mistral) fail to process the request. Hence, removing this specific property from the JSON schema - This issue was uncovered by MistralAiChatModelIT#chatMemoryWithTools where the method toolcallback is used - Update tests to remove "format" from the expected JSON schema Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com>
8326985 to
e9c9ad8
Compare
ilayaperumalg
commented
Sep 30, 2025
| } | ||
| ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType); | ||
| // Remove OpenAPI format as some LLMs (like Mistral) don't handle them. | ||
| parameterNode.remove("format"); |
Member
Author
There was a problem hiding this comment.
When the parameterNode doesn't contain "format", this operation just returns null and hence we don't need explicit check on the existence of this property.
ilayaperumalg
commented
Sep 30, 2025
| } | ||
| ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType); | ||
| // Remove OpenAPI format as some LLMs (like Mistral) don't handle them. | ||
| parameterNode.remove("format"); |
Member
Author
There was a problem hiding this comment.
It would be good to find out what other cases the OpenAPI format can be used in the context of ChatClient request.
spring-builds
pushed a commit
that referenced
this pull request
Oct 1, 2025
- For method input parameters, if the JSON schema generator adds OpenAPI "format" property, some LLMs (ex: Mistral) fail to process the request. Hence, removing this specific property from the JSON schema - This issue was uncovered by MistralAiChatModelIT#chatMemoryWithTools where the method toolcallback is used - Update tests to remove "format" from the expected JSON schema Fixes #4524 Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com> (cherry picked from commit 30001ac)
Willam2004
pushed a commit
to Willam2004/spring-ai
that referenced
this pull request
Oct 11, 2025
…4524) - For method input parameters, if the JSON schema generator adds OpenAPI "format" property, some LLMs (ex: Mistral) fail to process the request. Hence, removing this specific property from the JSON schema - This issue was uncovered by MistralAiChatModelIT#chatMemoryWithTools where the method toolcallback is used - Update tests to remove "format" from the expected JSON schema Auto-cherry-pick to 1.0.x Fixes spring-projects#4524 Signed-off-by: Ilayaperumal Gopinathan <ilayaperumal.gopinathan@broadcom.com> Signed-off-by: 家娃 <guanjing.pangj@alibaba-inc.com>
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.
Auto-cherry-pick to 1.0.x
Fixes #4524