[PR #11705] [MERGED] tools: support anyOf types #44856

Closed
opened 2026-04-25 00:32:01 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ollama/ollama/pull/11705
Author: @drifkin
Created: 8/5/2025
Status: Merged
Merged: 8/6/2025
Merged by: @drifkin

Base: mainHead: drifkin/fn-schema


📝 Commits (1)

  • 30f8a68 tools: support anyOf types

📊 Changes

7 files changed (+264 additions, -154 deletions)

View changed files

📝 api/types.go (+58 -10)
api/types_typescript_test.go (+142 -0)
📝 openai/openai_test.go (+6 -16)
📝 server/routes_generate_test.go (+12 -32)
📝 server/routes_harmony_streaming_test.go (+12 -32)
📝 template/template.go (+10 -0)
📝 tools/tools_test.go (+24 -64)

📄 Description

afaik gpt-oss is the first model that meaningfully transforms tool function definitions in its template. We found that relatively common definitions that include anyOf were not working because the template was assuming that types were always defined via a type field.

anyOf allows for fully recursive types, so I exposed a toTypeScriptType() function to handle this recursive logic in go and keep the templates cleaner. The gpt-oss templates will need to be updated to use this.

We should keep building out our function definition support to more fully support the parts of json schema that make sense for this use case, but in the meantime this will unblock some users (e.g., zed's ollama integration w/ gpt-oss). Probably the most urgent is proper array support


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ollama/ollama/pull/11705 **Author:** [@drifkin](https://github.com/drifkin) **Created:** 8/5/2025 **Status:** ✅ Merged **Merged:** 8/6/2025 **Merged by:** [@drifkin](https://github.com/drifkin) **Base:** `main` ← **Head:** `drifkin/fn-schema` --- ### 📝 Commits (1) - [`30f8a68`](https://github.com/ollama/ollama/commit/30f8a68c4cc55e0f3a717b891931847c97190843) tools: support anyOf types ### 📊 Changes **7 files changed** (+264 additions, -154 deletions) <details> <summary>View changed files</summary> 📝 `api/types.go` (+58 -10) ➕ `api/types_typescript_test.go` (+142 -0) 📝 `openai/openai_test.go` (+6 -16) 📝 `server/routes_generate_test.go` (+12 -32) 📝 `server/routes_harmony_streaming_test.go` (+12 -32) 📝 `template/template.go` (+10 -0) 📝 `tools/tools_test.go` (+24 -64) </details> ### 📄 Description afaik gpt-oss is the first model that meaningfully transforms tool function definitions in its template. We found that relatively common definitions that include `anyOf` were not working because the template was assuming that types were always defined via a `type` field. anyOf allows for fully recursive types, so I exposed a `toTypeScriptType()` function to handle this recursive logic in go and keep the templates cleaner. The gpt-oss templates will need to be updated to use this. We should keep building out our function definition support to more fully support the parts of json schema that make sense for this use case, but in the meantime this will unblock some users (e.g., zed's ollama integration w/ gpt-oss). Probably the most urgent is proper array support --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-25 00:32:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/ollama#44856