Skip to content

[FEATURE]:Support Gemini API by trimming/adapting tool descriptions #9570

Closed

Description

@sowar1987

Feature hasn't been suggested before.

  • I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

Problem

When using Gemini models (via @ai-sdk/openai-compatible or direct proxy), any tool invocation fails with:
Request contains an invalid argument (400)
This happens because:

  1. OpenCode's tool descriptions are very long (~4000+ chars for bash tool)
  2. Gemini API has stricter limits on function description length
  3. Normal chat works, but any tool call triggers the error

Environment

  • OpenCode version: 1.1.26
  • Provider: Gemini 3 Pro via openai-compatible proxy
  • OS: Windows

Expected Behavior

Gemini should work as a model provider with tool calling support.

Suggested Solution

Add provider-specific tool description trimming in transform.ts, similar to existing normalizeMessages() for Anthropic/Mistral:

if (model.api.id.includes("gemini")) {
  // Trim tool descriptions to Gemini's limits
}
Additional Context

•  Claude and OpenAI work fine with current tool descriptions
•  This affects all agents (Sisyphus, Build, etc.) - not agent-specific
•  Error log attached

[error-v1-chat-completions-2026-01-20T142434-138bff82.log](https://github.com/user-attachments/files/24732436/error-v1-chat-completions-2026-01-20T142434-138bff82.log)

Activity

  1. added
    discussionUsed for feature requests, proposals, ideas, etc. Open discussion
    on Jan 20, 2026
  2. github-actions commented on Jan 20, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    These issues relate to Gemini API compatibility problems with tool descriptions and parameters validation. Issue #9233 and #8184 specifically address similar errors with Gemini models failing on tool validation, and #5715 discusses the bash tool description being too long for certain providers.

    Feel free to ignore if none of these address your specific case.

  3. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

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

  4. jayteaftw commented on Apr 7, 2026

    @jayteaftw

    Hey why was this closed? Was this fixed? Im still experiencing this in 1.3.17

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

Metadata

Metadata

Assignees

Labels

discussionUsed for feature requests, proposals, ideas, etc. Open discussion

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions