Skip to content

types: allow additional properties in tool function schemas #542

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jonigl
Copy link

@jonigl jonigl commented Jul 16, 2025

Summary

This change is part of ollama/ollama#11444 and related to ollama/ollama#11448 where the server simplified ToolFunction.Parameters from a structured schema to json.RawMessage for better flexibility and performance.

Problem: The previous structured approach was limiting JSON schema flexibility and preventing support for advanced tooling scenarios that require complete schema definitions.

What changed

  • Added extra='allow' to Tool.Function.Parameters and Property model configurations
  • Enables Pydantic models to accept additional fields beyond explicitly defined ones

Why

  • Supports complex JSON schemas with custom properties when sending tool definitions to Ollama API
  • Resolves validation errors for schemas containing additional fields like validation rules, examples, or vendor extensions
  • Improves compatibility with rich tool schema definitions

Related

Enable Pydantic's extra='allow' for Parameters and Property classes
to support complex JSON schemas with arbitrary additional fields.
This allows complex JSON schemas with additional fields when sending tool
definitions to the Ollama API.

Fixes compatibility with ollama#11444"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants