Skip to content

Conversation

ilayaperumalg
Copy link
Member

@ilayaperumalg ilayaperumalg commented Sep 30, 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

Auto-cherry-pick to 1.0.x
Fixes #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

Signed-off-by: Ilayaperumal Gopinathan <[email protected]>
@ilayaperumalg ilayaperumalg force-pushed the mistral-methodtoolcallback-fix branch from 8326985 to e9c9ad8 Compare September 30, 2025 23:22
}
ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType);
// Remove OpenAPI format as some LLMs (like Mistral) don't handle them.
parameterNode.remove("format");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

}
ObjectNode parameterNode = SUBTYPE_SCHEMA_GENERATOR.generateSchema(parameterType);
// Remove OpenAPI format as some LLMs (like Mistral) don't handle them.
parameterNode.remove("format");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to find out what other cases the OpenAPI format can be used in the context of ChatClient request.

@markpollack markpollack merged commit 30001ac into spring-projects:main Oct 1, 2025
2 checks passed
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 <[email protected]>
(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 <[email protected]>
Signed-off-by: 家娃 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants