-
-
Notifications
You must be signed in to change notification settings - Fork 258
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Basic checks
- I searched existing issues - this hasn't been reported
- I can reproduce this consistently
- This is a RubyLLM bug, not my application code
What's broken?
The convert_schema_to_gemini
method in the Gemini provider has several issues that limit its functionality:
- Description fields are stripped from all schema types - Important schema documentation is lost during transformation
- Integer and Number types are incorrectly merged - Both
integer
andnumber
are converted toNUMBER
, losing type specificity - Inconsistent schema transformation approach - Gemini is the ONLY provider that transforms schemas; all other providers (OpenAI, Anthropic, Mistral, Bedrock) pass schemas directly to their APIs
The gem should either:
- Support all schema fields that Gemini officially supports, or
- Remove schema transformations entirely and let developers handle this themselves (consistent with OpenAI, Anthropic, Mistral, and Bedrock providers)
How to reproduce
Issue 1: Description Fields Stripped From Schema
# Define a schema with a description
schema = {
type: 'object',
description: 'An object',
properties: {
example: {
type: "string",
description: "a brief description about the person's time at the conference"
}
},
required: ['example']
}
chat = RubyLLM.chat(model: 'gemini-2.5-flash')
chat.with_schema(schema)
response = chat.ask('Generate an object')
response.content
{"example" => "hello"} # notice response did not adhere to schema because schema field description was stripped
# Expected: Descriptions should be preserved in API call
# Actual: All description fields are stripped
# Example of expected content:
{"description" => "The person attended various keynotes and workshops, finding the networking opportunities particularly valuable."}
Issue 2: Integer vs Number Type Loss
# Define schema with both number and integer types
schema = {
type: 'object',
properties: {
number1: {
type: 'number',
},
number2: {
type: 'integer',
}
}
}
chat = RubyLLM.chat(model: 'gemini-2.5-flash')
chat.with_schema(schema)
response = chat.ask('Generate an object')
response.content
{"number1" => 100.5, "number2" => 25.75} # notice number2 is still a number type despite the schema field type labeled as integer
# Expected: price should be NUMBER, quantity should be INTEGER
# Actual: Both are converted to NUMBER type
# Example of expected content:
{"number1" => 19.99, "number2" => 20}
Expected behavior
All schema fields supported by Gemini should be preserved:
- Objects:
description
,properties
,required
- Strings:
description
,enum
,format
,nullable
- Numbers:
description
,format
,minimum
,maximum
,enum
,nullable
- Integers:
description
,format
,minimum
,maximum
,enum
,nullable
- Arrays:
description
,minItems
,maxItems
,items
,nullable
- Booleans:
description
,nullable
See steps to reproduce for the expected output from specific examples
What actually happened
The method currently strips important schema information:
- Description fields are completely ignored for all types
- Integer schemas are converted to NUMBER type instead of INTEGER
- Only basic type conversion is performed
Environment
- RubyLLM version: 1.6.2
- Ruby version: 3.4.3
- Provider: Gemini
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working