ollama-python icon indicating copy to clipboard operation
ollama-python copied to clipboard

types: allow additional properties in tool function schemas

Open jonigl opened this issue 5 months ago • 0 comments

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

  • https://github.com/ollama/ollama/issues/11444
  • https://github.com/ollama/ollama/pull/11448

jonigl avatar Jul 16 '25 21:07 jonigl