Skip to content

fix(gemini): infer string type for enum schemas in anyOf/oneOf#1547

Merged
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
CMLKevin:clawoss/fix/1540-schema-enum
Mar 29, 2026
Merged

fix(gemini): infer string type for enum schemas in anyOf/oneOf#1547
joshua-mo-143 merged 1 commit into0xPlaygrounds:mainfrom
CMLKevin:clawoss/fix/1540-schema-enum

Conversation

@CMLKevin
Copy link
Copy Markdown
Contributor

Fixes #1540

Description

Schema conversion for Option<enum> fields (anyOf/oneOf containing objects with an enum key) was producing an empty type string, causing a 400 Bad Request from the Gemini API.

The root cause is in extract_type_from_composition: when iterating over anyOf/oneOf schemas, it checks for an explicit type field and properties, but not for the enum key. Enum schemas without an explicit type were falling through to None and ultimately returning an empty string.

The fix adds an else if obj.contains_key("enum") branch that returns "string".

Changes

  • rig-core/src/providers/gemini/completion.rs: Added enum key check in extract_type_from_composition to return "string"

Testing

cargo test -p rig-core --lib passes (439 tests).

@joshua-mo-143
Copy link
Copy Markdown
Contributor

thank you! lgtm

@joshua-mo-143 joshua-mo-143 added this pull request to the merge queue Mar 29, 2026
Merged via the queue into 0xPlaygrounds:main with commit 862ed7e Mar 29, 2026
6 checks passed
@github-actions github-actions Bot mentioned this pull request Mar 29, 2026
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.

bug: Gemini tools: Schema conversion fails for Option<enum> (anyOf + nested oneOf), emits empty type and triggers 400 Bad Request

2 participants