Skip to content

fix(vertex): convert Claude format request for Gemini models in Verte…#3405

Open
togawa-sakiko wants to merge 1 commit intoQuantumNous:mainfrom
togawa-sakiko:fix/vertex-claude-to-gemini-convert
Open

fix(vertex): convert Claude format request for Gemini models in Verte…#3405
togawa-sakiko wants to merge 1 commit intoQuantumNous:mainfrom
togawa-sakiko:fix/vertex-claude-to-gemini-convert

Conversation

@togawa-sakiko
Copy link

@togawa-sakiko togawa-sakiko commented Mar 23, 2026

Problem

When routing a Claude-format request (/v1/messages) through a Vertex channel with a Gemini model, the request was sent to the Gemini endpoint still in Anthropic format, causing an error.

Root Cause

ConvertClaudeRequest in the Vertex adaptor always returned the request as Anthropic format (via copyRequest), regardless of RequestMode. It lacked the RequestModeGemini branch that ConvertOpenAIRequest already handles correctly.

Fix

Add a RequestModeGemini branch in ConvertClaudeRequest that delegates to gemini.Adaptor.ConvertClaudeRequest, which performs the correct Claude → (OpenAI →) Gemini conversion.

if a.RequestMode == RequestModeGemini {
    geminiAdaptor := gemini.Adaptor{}
    return geminiAdaptor.ConvertClaudeRequest(c, info, request)
}

Summary by CodeRabbit

Release Notes

  • Improvements
    • Enhanced request processing with intelligent adaptive routing capabilities. The adapter now intelligently routes requests to the appropriate handler based on the active model mode configuration. This improvement enhances flexibility and support for multiple model types while preserving backward compatibility with existing request handling behavior.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Mar 23, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1f724622-5e5b-4ae5-b739-1aebede6c1e3

📥 Commits

Reviewing files that changed from the base of the PR and between 9ae9040 and 298e8e4.

📒 Files selected for processing (1)
  • relay/channel/vertex/adaptor.go

Walkthrough

The ConvertClaudeRequest method in the Vertex adaptor now conditionally routes Claude request conversion: if the request mode is Gemini, it delegates to a Gemini adaptor; otherwise, it uses the existing Claude-specific conversion logic.

Changes

Cohort / File(s) Summary
Vertex Adaptor Conditional Routing
relay/channel/vertex/adaptor.go
Added conditional logic to ConvertClaudeRequest that delegates to Gemini adaptor when RequestModeGemini, otherwise preserves existing Claude request handling behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Possibly related PRs

Suggested reviewers

  • seefs001

Poem

🐰 A clever fork in the road appears,
Where Claude meets Gemini's frontier,
The adaptor now knows which way to go—
Routing requests with a thoughtful flow!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding support for converting Claude-format requests to Gemini format in the Vertex adaptor, which directly addresses the root cause of the bug described in the PR objectives.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant