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

Open
opened 2026-02-16 18:05:33 -05:00 by yindo · 1 comment
Owner

Originally created by @sowar1987 on GitHub (Jan 20, 2026).

Originally assigned to: @thdxr on GitHub.

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)
Originally created by @sowar1987 on GitHub (Jan 20, 2026). Originally assigned to: @thdxr on GitHub. ### Feature hasn't been suggested before. - [x] 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: ```typescript 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)
yindo added the discussion label 2026-02-16 18:05:33 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 20, 2026):

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

  • #9233: LiteLLM Proxy: Vertex AI Gemini models fail for tools with empty parameters
  • #8184: Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters)
  • #5715: The problem of overly long bash description

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.

@github-actions[bot] commented on GitHub (Jan 20, 2026): This issue might be a duplicate of existing issues. Please check: - #9233: LiteLLM Proxy: Vertex AI Gemini models fail for tools with empty parameters - #8184: Strict JSON Schema validation fail on backends like SGLang (Missing required field in empty tool parameters) - #5715: The problem of overly long bash description 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.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6903