Zhuoxi2000 opened a new issue, #1014: URL: https://github.com/apache/flink-agents/issues/1014
### Search before asking - [x] I searched in the [issues](https://github.com/apache/flink-agents/issues) and found nothing similar. ### Description `OllamaChatModelConnection.convertToOllamaTools` assumes the tool schema always has a `required` list: final List<String> required = (List<String>) schema.get("required"); ... .required(required.contains(paramName)) But `required` is optional in JSON Schema, and `SchemaUtils.generateSchema` only emits it when at least one parameter is required. That means a Java `@Tool` whose parameters are all optional produces a valid schema without `required`, and the Ollama connector throws an NPE while building the request. Expected: all-optional tools are converted normally, with each property marked `required(false)`. Actual: `required` is `null`, so `required.contains(...)` fails before the request reaches Ollama. Tools with at least one required parameter are unaffected. The fix should be small: treat a missing `required` field as an empty list in `convertToOllamaTools`, and add a regression test for a schema with no `required` key. I think hardening the consumer is preferable to changing `SchemaUtils`, since omitting an empty `required` list is valid JSON Schema, but happy to follow whichever direction maintainers prefer. ### How to reproduce 1. Define a Java tool with at least one optional parameter: public class DemoTools { @Tool(description = "List recent orders") public static String listOrders( @ToolParam(name = "limit", required = false) Integer limit) { return "[]"; } } An unannotated parameter reproduces the same issue, since it is also omitted from the schema’s `required` list. 2. Register the tool with an Ollama chat model and send any request that includes it. 3. `convertToOllamaTools` fails with: java.lang.NullPointerException: Cannot invoke "java.util.List.contains(Object)" because "required" is null A zero-parameter tool does not trigger this because there are no properties to iterate over. The failing case is a tool with one or more parameters where none are required. ### Version and environment Current main (3070ee2). Java 11+, any OS; independent of the Ollama server version — the NPE is thrown client-side during request construction. ### Are you willing to submit a PR? - [x] I'm willing to submit a PR! -- 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]
