[Bug][integrations][java] Ollama tool conversion fails on nullable tool parameters
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 84/100
Research direction
Start with OllamaChatModelConnection.convertToOllamaTools in integrations/chat-models/ollama/src/main/java/org/apache/flink/agents/integrations/chatmodels/ollama/OllamaChatModelConnection.java and the conversion coverage in OllamaChatModelConnectionTest. Reproduce the failure with a schema whose property type is ["string", "null"], then check how the non-null type should be passed to Ollama. Done when conversion succeeds and the test verifies the parameter is sent as its non-null type.
Written by the indexing model from the issue text.
Description
Search before asking
- I searched in the issues and found nothing similar.
Description
A Java function tool with a nullable parameter cannot be used with the Java Ollama chat model.
FunctionSchema writes @ToolParam(nullable = true) as "type": [<type>, "null"] (plan/src/main/java/org/apache/flink/agents/plan/tools/FunctionSchema.java:186). OllamaChatModelConnection.convertToOllamaTools reads every property's type as a String (integrations/chat-models/ollama/src/main/java/org/apache/flink/agents/integrations/chatmodels/ollama/OllamaChatModelConnection.java:158).
Expected: the tool converts, with the parameter sent as its non-null type.
Actual: every chat call with that tool fails with RuntimeException: java.lang.ClassCastException: class java.util.ArrayList cannot be cast to class java.lang.String.
The Python Ollama connection passes the schema through and is not affected.
How to reproduce
In OllamaChatModelConnectionTest, convert a tool whose schema is:
{"type":"object","properties":{"city":{"type":["string","null"]}},"required":["city"]}
connection().convertToOllamaTools(List.of(new SchemaOnlyTool(schema))) throws the ClassCastException above.
Version and environment
main at 5b0b5531, Java 17, macOS.
Are you willing to submit a PR?
- I'm willing to submit a PR!
- Dominant language
- Java
- Stars
- 491
- Forks
- 184
- Avg merge
- 1d 17h
- Merged PRs (30d)
- 69
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from apache/flink-agents
-
bug priority/major
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
apache/flink-agents#1394 · 1 comment ·
Maintainers usually reply within 1 day
-
[Bug][plan][java][python] BashTool accepts unlisted bare commands when cwd is allowedPossibly taken @wenjin272 claimed this today. Openbug priority/major
apache/flink-agents#1392 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Tech Debt] Unify embedding model result APIs across Java and PythonPossibly taken @wenjin272 claimed this 4 days ago. Openpriority/major tech debt
apache/flink-agents#1385 · 1 assignee ·
Maintainers usually reply within 1 day
-
[Feature][api] Standardize framework duration configurationPossibly taken @HsbcJone claimed this 4 days ago. Open
Difficulty 4/5 3-5 days Newbie friendliness 43/100
apache/flink-agents#1384 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
apache/flink-agents#1381 ·
Maintainers usually reply within 1 day
All issues in apache/flink-agents
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
floci-io/floci#8666 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 68/100
quarkiverse/quarkiverse#476 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
chinabugotech/hutool#4364 · 1 comment ·
Maintainers usually reply within 1 day
-
lesson-submission pending-review
Difficulty 1/5 Under an hour Newbie friendliness 72/100
Ikalus1988/MisakaNet#5115 ·
Maintainers usually reply within 1 day
-
bug good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
crowdin/crowdin-api-client-java#441 ·
Maintainers usually reply within 1 day