[GH-ISSUE #6377] Full(er) JSON Schema support for tool calling #50517

Closed
opened 2026-04-28 16:09:17 -05:00 by GiteaMirror · 4 comments
Owner

Originally created by @mitar on GitHub (Aug 15, 2024).
Original GitHub issue: https://github.com/ollama/ollama/issues/6377

Currently parameters in tool definition is a very limited subset of a JSON Schema. This makes it non-compatible with OpenAI (https://github.com/ollama/ollama/issues/6155) and it general it makes it really hard to use it because you cannot pass JSON Schema as parameters but have to manually map to the API structure tool definition expects. Good enough if you are manually making a tool definition, but hard if you have automatic process to generate JSON Schema (for example, I use https://github.com/invopop/jsonschema Go package to generate JSON Schema from Go struct automatically, which works great with other API providers like OpenAI).

So I would suggest that API is relaxed to get embedded JSON Schema and not just fixed structure it currently allows.

Originally created by @mitar on GitHub (Aug 15, 2024). Original GitHub issue: https://github.com/ollama/ollama/issues/6377 Currently `parameters` in tool definition is a very limited subset of a JSON Schema. This makes it non-compatible with OpenAI (https://github.com/ollama/ollama/issues/6155) and it general it makes it really hard to use it because you cannot pass JSON Schema as `parameters` but have to manually map to the API structure tool definition expects. Good enough if you are manually making a tool definition, but hard if you have automatic process to generate JSON Schema (for example, I use https://github.com/invopop/jsonschema Go package to generate JSON Schema from Go struct automatically, which works great with other API providers like OpenAI). So I would suggest that API is relaxed to get embedded JSON Schema and not just fixed structure it currently allows.
GiteaMirror added the feature requestapi labels 2026-04-28 16:09:17 -05:00
Author
Owner

@mitar commented on GitHub (Aug 15, 2024):

Also the Parameters struct from ToolFunction should be an exported symbol in Go API so that it is possible to unmarshal JSON directly into that struct.

<!-- gh-comment-id:2292214934 --> @mitar commented on GitHub (Aug 15, 2024): Also the `Parameters` struct from `ToolFunction` should be an exported symbol in Go API so that it is possible to unmarshal JSON directly into that struct.
Author
Owner

@adela185 commented on GitHub (Aug 30, 2024):

I would also like to bring attention to this addition. It seems like tool calling jsons only go two levels deep at the point that the prompt is generated. Any extra nested properties or keys beyond are truncated. This limits ability for complex tooll calls.

<!-- gh-comment-id:2321151502 --> @adela185 commented on GitHub (Aug 30, 2024): I would also like to bring attention to this addition. It seems like tool calling jsons only go two levels deep at the point that the prompt is generated. Any extra nested properties or keys beyond are truncated. This limits ability for complex tooll calls.
Author
Owner

@jonigl commented on GitHub (Jul 16, 2025):

Hi there! I ran into the same issue and wanted to share my findings. I opened this issue, where I describe what I discovered and propose a possible solution.

To address the problem, I’ve also submitted two PRs to refactor the related behavior:

Would love any feedback or thoughts on it thanks!

<!-- gh-comment-id:3081596959 --> @jonigl commented on GitHub (Jul 16, 2025): Hi there! I ran into the same issue and wanted to share my findings. I opened [this issue](https://github.com/ollama/ollama/issues/11444), where I describe what I discovered and propose a possible solution. To address the problem, I’ve also submitted two PRs to refactor the related behavior: * [PR #11448 (ollama/ollama)](https://github.com/ollama/ollama/pull/11448) * [PR #542 (ollama/ollama-python)](https://github.com/ollama/ollama-python/pull/542)python/pull/542) Would love any feedback or thoughts on it thanks!
Author
Owner

@mitar commented on GitHub (Oct 7, 2025):

It looks like ToolFunctionParameters is now available.

<!-- gh-comment-id:3378676520 --> @mitar commented on GitHub (Oct 7, 2025): It looks like `ToolFunctionParameters` is now available.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#50517