Skip to content

Bug Report: Gemini fails with built-in tools enabled due to invalid tool schema #655

Closed

Description

@Yashraj0888

Environment

  • Jcode Version: Workshop v0.61.1
  • Provider: Gemini (OAuth)
  • Model: gemini-2.5-pro
  • Platform: macOS
  • Authentication: OAuth login succeeds successfully.

Summary

Gemini works correctly until Jcode includes its built-in tools. Any request with the default toolset enabled fails with an HTTP 400 because one of the generated function declarations contains an invalid JSON schema.

Disabling the built-in tools makes the exact same request succeed.


Steps to Reproduce

  1. Log into Gemini:
jcode login --provider gemini
  1. Verify authentication:
jcode auth-test --all-configured

Authentication succeeds:

  • ✅ Credential probe
  • ✅ Refresh probe
  • ✅ Provider smoke (AUTH_TEST_OK)
  1. Run a simple prompt:
jcode run "hello"

Actual Result

Gemini returns:

Gemini generateContent failed

GenerateContentRequest.tools[0].function_declarations[25].parameters.any_of[0].required[1]: property is not defined

Earlier interactive runs also produced:

HTTP 400 Bad Request

Unable to submit request because required fields ['label'] are not defined in the schema properties.

Expected Result

The prompt should execute normally and return a response from Gemini.


Workaround

Running with built-in tools disabled works correctly:

jcode run --disable-base-tools "hello"

Output:

Hello! I'm Jcode. How can I help you today?

This confirms that:

  • ✅ Gemini authentication is working.
  • ✅ OAuth is working.
  • ✅ The provider integration is working.
  • ❌ The failure only occurs when Jcode serializes the built-in tool/function declarations.

Additional Information

Running:

jcode auth-test --all-configured

returns:

  • ✅ credential_probe
  • ✅ refresh_probe
  • ✅ provider_smoke
  • ❌ tool_smoke

The provider itself is healthy, but tool-enabled requests fail.

My ~/.jcode/config.toml contains the default tool configuration:

[tools]
enabled = []
disabled = []
disable_base_tools = false

I do not have any custom tool configuration or custom MCP tools enabled.


Likely Cause

It appears that one of the built-in tool schemas is invalid for Gemini's JSON Schema validation.

Gemini reports:

GenerateContentRequest.tools[0].function_declarations[25].parameters.any_of[0].required[1]: property is not defined

and in another run:

required fields ['label'] are not defined in the schema properties.

This suggests that one of the generated function declarations contains a required field referencing a property that does not exist in the corresponding properties object.

OpenAI-based providers may accept this schema, but Gemini rejects it during request validation.


Reproduction Confirmation

The following commands reproduce the issue consistently:

# Works
jcode run --disable-base-tools "hello"

# Fails
jcode run "hello"

This strongly indicates that the issue lies in the built-in tool schema generation rather than authentication or the Gemini provider itself.

If helpful, I'm happy to test a development build or help identify which specific built-in tool is generating the invalid schema.

Activity

  1. added
    bug
    triage: reproducible
    autonomous: clear
    priority: critical
    on Jul 29, 2026
  2. 1jehuang commented on Jul 29, 2026

    @1jehuang
    Owner

    Thanks for the very thorough report. The --disable-base-tools comparison isolated it precisely, and your diagnosis was right: the required array referenced a property the same object did not declare.

    Concretely, the swarm tool builds mutually exclusive anyOf action branches so label is required only for spawn. The spawn branch declared required: ["action", "label"] but only declared action in its own properties, inheriting label from the parent schema. OpenAI-compatible providers accept that; Gemini validates required against the local properties map and rejects the whole request.

    Two changes, in #656:

    • The Gemini schema adapter now prunes required names that the same object does not declare, and drops a required array left empty. This makes the whole provider path resilient rather than fixing one tool.
    • The spawn branch now declares label explicitly, so the schema is well-formed at the source. A test asserts every branch only requires properties it declares.

    Verified with cargo test -p jcode-provider-gemini-runtime --lib (34 passed, 3 new) and -p jcode-app-core --lib communicate (79 passed, 1 new).

    I do not have Gemini OAuth credentials here, so this is verified at the schema layer rather than against the live endpoint. If you are willing to test a dev build off that branch, confirmation that jcode run "hello" now succeeds would be genuinely useful before it ships.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  3. 1jehuang commented on Jul 29, 2026

    @1jehuang
    Owner

    Final verification update, closing the last gap in how I had checked this.

    My earlier tests all operated on Rust structures rather than the JSON Gemini actually receives, so they could not strictly prove the request you were sending is now valid. I have now validated the serialized wire form.

    Method: pushed the real tool registry through the actual Gemini converter, serialized the result exactly as it goes on the wire, and checked every nested object against Gemini's rule that each required name must appear in the same object's properties (plus the empty-required case, which Gemini also rejects).

    With the fixes in place:

    function declarations checked: 28
    dangling required on the wire: 0
    empty required arrays on the wire: 0
    WIRE VALID
    

    With both fixes reverted, i.e. the version you were running:

    dangling required on the wire: 1
       tool[swarm].anyOf[0].required: 'label' not in properties
    WIRE INVALID
    

    That is the precise cause of your HTTP 400, reproduced and then resolved in the serialized payload. It also confirms swarm was the only offending declaration out of 28, so there is no second instance waiting behind this one.

    One more thing worth reporting: I checked the two fixes independently, and either one alone is sufficient. The adapter-level pruning is therefore a genuine safety net rather than redundant, since it protects any future tool that writes anyOf branches this way, not just the one that broke.

    Committed as 240e4e89e on #656, which asserts the invariant on the converted declarations permanently, so a regression fails CI rather than reaching a user.

    Remaining honest caveat, unchanged: I have no Gemini credentials here, so this is verified against Gemini's documented validation rule rather than a live generateContent call. If you are able to run a dev build off that branch, a confirmation that jcode run "hello" succeeds would close the loop completely.

    --- — Jcode agent (automated triage), on behalf of @1jehuang

  4. added a commit that references this issue on Jul 31, 2026
    41f9142
  5. added 4 commits that reference this issue on Aug 30, 2026
    cc3425b
    c7b436a
    af4e3ec
    ed033f3
  6. 5 remaining items

  7. added 3 commits that reference this issue on Sep 18, 2026
    edb4917
    3f1a058
    606919b
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    autonomous: clearbugpriority: criticaltriage: reproducible

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions