-
Notifications
You must be signed in to change notification settings - Fork 13k
tools: fix parsing tool calls with empty arguments or missing required fields #11233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
b9a2cea
to
8e01c60
Compare
8e01c60
to
21a253c
Compare
tools/tools.go
Outdated
// check for required parameters | ||
if valid { | ||
for _, required := range tool.Function.Parameters.Required { | ||
if _, exists := obj[required]; !exists { | ||
valid = false | ||
break | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So does the user get the tool call as a JSON instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the test it seems like we don't return anything. Might want to error out instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great point! Ollama should error if invalid parameters are sent to the tool (similar to other APIs). I added a TODO
and we should fix this in the near future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the test it seems like we don't return anything. Might want to error out instead
If you refer to ticket #11232 then please note that Qwen3 produced correct output, but Ollama converted it into incorrect JSON call request, so... one thing is to read correctly what was produced by model (this is what I've reported and it is important) and second thing is to validate if model followed tool definition (which is sounds like nice improvement, but in my mind it is low priority thing and might be challenging how to handle it correctly).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Tarmenale2 indeed, errors will be added in a follow up. This PR fixes the tool parsing issue you noticed in #11232
0a4186b
to
56e32ec
Compare
56e32ec
to
3a38f7e
Compare
* origin/main: ggml: Report ordinal IDs for AMD GPUs on Windows doc: add MacOS docs (ollama#11334) Reduce default parallelism to 1 (ollama#11330) API/CLI context enhancements (ollama#11331) add `tool_name` to api.md (ollama#11326) template: add tool result compatibility (ollama#11294) ci: modularization (ollama#11324) Revert "ggml: Temporarily disable reporting UUIDs" readme: update Ollama icon size int: add performance integration tests (ollama#11173) doc: add NVIDIA blackwell to supported list (ollama#11307) Update base image to Ubuntu 24.04 LTS (ollama#9681) doc: Update link for mac install (ollama#11288) mimic logs for layers on new engine (ollama#11278) readme: add NativeMind to community integrations (ollama#11242) tools: fix parsing tool calls with empty arguments, missing required fields (ollama#11233) readme: add ollama-bash-toolshed to community integrations (ollama#11224)
Tool call parsing was not correctly handling
"arguments": {}
, or considering required fields.Fixes #11232