[integration][ollama] Tolerate tool schemas without a 'required' key - #1026
Open
Zhuoxi2000 wants to merge 1 commit into
Open
[integration][ollama] Tolerate tool schemas without a 'required' key#1026Zhuoxi2000 wants to merge 1 commit into
Zhuoxi2000 wants to merge 1 commit into
Conversation
Zhuoxi2000
marked this pull request as ready for review
August 18, 2026 02:55
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.
Linked issue: #1014
Purpose of change
OllamaChatModelConnection.convertToOllamaToolsassumed the tool schema always carries arequiredlist, butrequiredis optional in JSON Schema andSchemaUtils.generateSchemaonly emits it when at least one parameter is required. A Java@Toolwhose parameters are all optional therefore produced a valid schema that crashed the Ollama connector with an NPE before the request reached the server. The same shape can come from external tools (e.g. an MCP tool with only optional parameters), so this hardens the consumer rather than changingSchemaUtils: a missingrequiredlist is treated as empty, and all-optional tools convert normally with every property markedrequired(false).Tests
New
OllamaChatModelConnectionTest(the module previously had no connection test): a schema without arequiredkey converts with every property optional, and a schema with arequiredkey still marks the listed parameters required. Both are pure unit tests of the conversion — no Ollama server needed.convertToOllamaToolswas narrowed from private to package-private for test access.API
None.
Documentation
doc-neededdoc-not-neededdoc-includedWas this patch authored or co-authored using generative AI tooling?
If yes, include a
Generated-by: <tool name and version> (<model name and version>)line, for exampleGenerated-by: Claude Code 2.1.226 (Claude Opus 4.6), in the commit message so it reaches Git history. Repeat the same line here for reviewer visibility. See the ASF generative tooling guidance.Generated-by: Claude Fable 5