Skip to content

question tool fails with Gemini models (SchemaError: Missing key at ["questions"] due to argument flattening) #35105

Closed as not planned

Description

@JensBoening1337

Description

Description

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 key
  at ["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.

Expected Serialization (Claude)

{
  "questions": [
    {
      "header": "Favorite Food",
      "multiple": false,
      "options": [
        {
          "description": "Delicious, cheesy, and versatile",
          "label": "Pizza"
        }
      ],
      "question": "What is your go-to comfort food?"
    }
  ]
}

Suggested Fix

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

  1. select any model from the gemini class
  2. prompt to ask any question using the question tool

Screenshot and/or share link

Image

Operating System

Ubuntu 24.04

Terminal

No response

Activity

  1. kagura-chen commented on Jul 3, 2026

    @kagura-chen
    Contributor

    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].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.

  2. github-actions commented on Sep 2, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions