fix: forward full JSON schema for function tool params to RubyLLM (2.0.5)#52
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Raix::FunctionToolAdapterrebuilt each function parameter field-by-field via RubyLLM'sparam(...), which only carriedtypeanddescription. Rich JSON-Schema fields —additionalProperties,items,enum, and nestedproperties— were silently dropped.The visible symptom: providers (notably Gemini structured output via OpenRouter) had no real schema for
type: objectarguments, 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 defaultsadditionalProperties: falseandstrict: trueat the outer schema (preserving prior behavior), while letting a function declaration override either by setting it explicitly.Tests
New
spec/raix/function_tool_adapter_spec.rbcovers:additionalPropertieson nested object params) survive toparams_schemaadditionalProperties: false,strict: true) preserved by defaultFull suite: 107 examples, 0 failures, 1 pending. RuboCop clean.
Versioning
2.0.4was 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