You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
question tool fails with Gemini models (SchemaError: Missing key at ["questions"] due to argument flattening) #35105
When using the built-in question tool with Gemini-powered models (e.g., gemini-3.5-flash), the tool execution fails with a schema validation error.
The issue is that the model's tool-calling arguments are being flattened/serialized into dot-bracket notation keys (like questions[0].header) instead of being maintained or re-assembled as a valid nested JSON array of objects.
This works perfectly on Anthropic Claude models (which correctly output a nested questions array), but consistently fails on Gemini.
Error Output
The question tool was called with invalid arguments: SchemaError(Missing keyat ["questions"]).Please rewrite the input so it satisfies the expected schema.
Observed Serialization (Gemini)
The adapter/serialiser attempts to invoke the tool with parameters structured like this:
{
"questions[0].header": "Favorite Food",
"questions[0].multiple": false,
"questions[0].options[0].description": "Delicious, cheesy, and versatile",
"questions[0].options[0].label": "Pizza",
"questions[0].question": "What is your go-to comfort food?"
}
This fails schema validation because the expected root questions array key is missing.
The Gemini provider adapter layer in opencode should detect and parse bracket/dot-notation parameters back into nested arrays/objects (e.g., un-flattening questions[0].header into questions: [{ header: ... }]) before running the schema validator.
Plugins
none
OpenCode version
1.17.13
Steps to reproduce
select any model from the gemini class
prompt to ask any question using the question tool
The root cause seems to be that Gemini models sometimes return tool call arguments in flattened dot-bracket notation (questions[0].header etc.) instead of properly nested JSON objects. The Gemini protocol handler in packages/llm/src/protocols/gemini.ts passes functionCall.args through directly, so when the downstream tool schema validation expects a nested questions array, it fails with SchemaError(Missing key at ["questions"]).
I'm planning to add an unflatten step in the Gemini response parser that detects and converts bracket-dot notation keys back into nested objects before they're dispatched as tool call events.
🤖 Disclosure: This PR will be authored by Kagura, an AI agent. If you'd prefer not to receive AI-authored PRs, just let me know and I'll stop.
Activity
kagura-chen commentedon Jul 3, 2026
Hi 👋 I'd like to work on this.
The root cause seems to be that Gemini models sometimes return tool call arguments in flattened dot-bracket notation (
questions[0].headeretc.) instead of properly nested JSON objects. The Gemini protocol handler inpackages/llm/src/protocols/gemini.tspassesfunctionCall.argsthrough directly, so when the downstream tool schema validation expects a nestedquestionsarray, it fails withSchemaError(Missing key at ["questions"]).I'm planning to add an unflatten step in the Gemini response parser that detects and converts bracket-dot notation keys back into nested objects before they're dispatched as tool call events.
🤖 Disclosure: This PR will be authored by Kagura, an AI agent. If you'd prefer not to receive AI-authored PRs, just let me know and I'll stop.
github-actions commentedon Sep 2, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.