Zhuoxi2000 opened a new pull request, #1026: URL: https://github.com/apache/flink-agents/pull/1026
<!-- * Thank you very much for contributing to Flink Agents. * Please add the relevant components in the PR title. E.g., [api], [runtime], [java], [python], [hotfix], etc. --> <!-- Please link the PR to the relevant issue(s). Hotfix doesn't need this. --> Linked issue: #1014 ### Purpose of change <!-- What is the purpose of this change? --> `OllamaChatModelConnection.convertToOllamaTools` assumed the tool schema always carries a `required` list, but `required` is optional in JSON Schema and `SchemaUtils.generateSchema` only emits it when at least one parameter is required. A Java `@Tool` whose 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 changing `SchemaUtils`: a missing `required` list is treated as empty, and all-optional tools convert normally with every property marked `required(false)`. ### Tests <!-- How is this change verified? --> New `OllamaChatModelConnectionTest` (the module previously had no connection test): a schema without a `required` key converts with every property optional, and a schema with a `required` key still marks the listed parameters required. Both are pure unit tests of the conversion — no Ollama server needed. `convertToOllamaTools` was narrowed from private to package-private for test access. ### API <!-- Does this change touches any public APIs? --> None. ### Documentation <!-- Do not remove this section. Check the proper box only. --> - [ ] `doc-needed` <!-- Your PR changes impact docs --> - [x] `doc-not-needed` <!-- Your PR changes do not impact docs --> - [ ] `doc-included` <!-- Your PR already contains the necessary documentation updates --> ### Was this patch authored or co-authored using generative AI tooling? <!-- Do not remove this section. Check the proper box only. --> - [x] Yes - [ ] No If yes, include a `Generated-by: <tool name and version> (<model name and version>)` line, for example `Generated-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](https://www.apache.org/legal/generative-tooling.html). Generated-by: Claude Fable 5 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
