Skip to content

fix: forward full JSON schema for function tool params to RubyLLM (2.0.5)#52

Merged
obie merged 2 commits into
mainfrom
fix-function-tool-adapter-rich-schema
Jun 4, 2026
Merged

fix: forward full JSON schema for function tool params to RubyLLM (2.0.5)#52
obie merged 2 commits into
mainfrom
fix-function-tool-adapter-rich-schema

Conversation

@obie

@obie obie commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

What

Raix::FunctionToolAdapter rebuilt each function parameter field-by-field via RubyLLM's param(...), which only carried type and description. Rich JSON-Schema fields — additionalProperties, items, enum, and nested properties — were silently dropped.

The visible symptom: providers (notably Gemini structured output via OpenRouter) had no real schema for type: object arguments, so they invented degenerate shapes — e.g. emitting {"prefix" => false} instead of {"prefix:title" => "..."}.

Fix

Forward the full schema dict via RubyLLM's params(schema) path instead of rebuilding it.

That path forwards the schema verbatim and, unlike param(...), does not inject the OpenAI strict-mode guards. So the adapter now defaults additionalProperties: false and strict: true at the outer schema (preserving prior behavior), while letting a function declaration override either by setting it explicitly.

params({ additionalProperties: false, strict: true }.merge(function_def[:parameters]))

Tests

New spec/raix/function_tool_adapter_spec.rb covers:

  • Rich JSON-Schema fields (additionalProperties on nested object params) survive to params_schema
  • Outer strict-mode guards (additionalProperties: false, strict: true) preserved by default
  • No-parameter functions still produce no schema

Full suite: 107 examples, 0 failures, 1 pending. RuboCop clean.

Versioning

2.0.4 was already released upstream for an unrelated change, so this cuts 2.0.5 and rolls the pending temperature-default fix out of [Unreleased] into [2.0.5] alongside this fix.

🤖 Generated with Claude Code

obie and others added 2 commits June 4, 2026 11:01
FunctionToolAdapter rebuilt each parameter field-by-field via `param(...)`,
which only carried `type` and `description`. Rich JSON-Schema fields such as
`additionalProperties`, `items`, `enum`, and nested `properties` were silently
dropped, so providers (notably Gemini structured output via OpenRouter) had to
invent degenerate shapes for `type: object` arguments — e.g. `{"prefix" => false}`
instead of `{"prefix:title" => "..."}`.

Forward the full schema dict via RubyLLM's `params(schema)` instead. That path
does not inject the OpenAI strict-mode guards the `param(...)` path got for free,
so default `additionalProperties: false` and `strict: true` at the outer schema
while letting a function declaration override either explicitly.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2.0.4 was already released upstream for an unrelated change, so this cuts 2.0.5.
Moves the pending temperature-default fix out of [Unreleased] into [2.0.5]
alongside the FunctionToolAdapter rich-schema fix.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@obie obie merged commit 1d44179 into main Jun 4, 2026
1 check passed
@obie obie deleted the fix-function-tool-adapter-rich-schema branch June 4, 2026 09:12
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.

1 participant