Skip to content

fix: volcengine claude DoResponse - #2296

Merged
Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
seefs001:fix/adapter-missing
Nov 25, 2025
Merged

Calcium-Ion merged 2 commits into
QuantumNous:mainfrom
seefs001:fix/adapter-missing

Conversation

@seefs001

@seefs001 seefs001 commented Nov 25, 2025 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

Release Notes

  • Refactor
    • Optimized internal request routing architecture for improved maintainability and flexibility across different channel configurations.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Nov 25, 2025 •

Copy link
Copy Markdown
Contributor

Walkthrough

Two channel adaptors modified to route Claude requests differently: baidu_v2 now entirely delegates to openai.Adaptor, while volcengine branches on ChannelBaseUrl—using claude.Adaptor for DoubaoCodingPlan and openai.Adaptor otherwise. Both ConvertClaudeRequest and response handling are affected.

Changes

Cohort / File(s) Change Summary
Baidu V2 Unified Routing
relay/channel/baidu_v2/adaptor.go
Removed claude import; ConvertClaudeRequest now constructs and delegates to openai.Adaptor instead of claude.Adaptor
VolcEngine Conditional Routing
relay/channel/volcengine/adaptor.go
ConvertClaudeRequest branches on ChannelBaseUrl: routes to claude.Adaptor for DoubaoCodingPlan, otherwise to openai.Adaptor; DoResponse similarly scopes Claude handling based on channel base URL and relay format

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

  • volcengine/adaptor.go: Verify branching logic correctness in both ConvertClaudeRequest and DoResponse methods; ensure ChannelBaseUrl comparison against DoubaoCodingPlan is properly handled in both request and response paths.
  • baidu_v2/adaptor.go: Confirm that openai.Adaptor.ConvertClaudeRequest correctly handles all Claude request scenarios previously handled by claude.Adaptor.

Possibly related PRs

Suggested reviewers

  • Calcium-Ion

Poem

🐰 The adaptors now know when to dance,

Baidu trusts OpenAI's advance,

VolcEngine picks paths with care—

Some routes to Claude, others elsewhere!

Code flows cleaner through the air. ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Title check ⚠️ Warning The title focuses on 'volcengine claude DoResponse' but the changeset includes significant modifications to both baidu_v2 and volcengine adaptors, with the baidu_v2 change being a complete removal of claude handling. Revise the title to reflect all major changes, such as 'fix: refactor Claude request handling across adaptors' or specify whether volcengine is the primary focus.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4866b3d and 581bf33.

📒 Files selected for processing (2)
  • relay/channel/baidu_v2/adaptor.go (1 hunks)
  • relay/channel/volcengine/adaptor.go (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-05T17:14:17.246Z
Learnt from: neotf
Repo: QuantumNous/new-api PR: 1511
File: setting/ratio_setting/model_ratio.go:118-123
Timestamp: 2025-08-05T17:14:17.246Z
Learning: Claude models handle "-thinking" variants differently from Gemini models. For Claude models, only the base model (without "-thinking") gets an entry in defaultModelRatio map. The "-thinking" variants rely on the Claude relay handler stripping the suffix using strings.TrimSuffix(textRequest.Model, "-thinking") before looking up the ratio, so they automatically use the base model's ratio.

Applied to files:

  • relay/channel/volcengine/adaptor.go
🧬 Code graph analysis (1)
relay/channel/baidu_v2/adaptor.go (2)
relay/channel/openai/adaptor.go (1)
  • Adaptor (36-39)
relay/channel/claude/adaptor.go (1)
  • Adaptor (24-26)
🔇 Additional comments (3)
relay/channel/baidu_v2/adaptor.go (1)

28-31: LGTM - Consistent adaptor usage for Claude requests.

The change aligns ConvertClaudeRequest with DoResponse (lines 118-122), both now using openai.Adaptor. This ensures request conversion and response handling use the same adaptor, maintaining consistency.

relay/channel/volcengine/adaptor.go (2)

42-49: LGTM - Conditional Claude adaptor routing.

The branching correctly routes DoubaoCodingPlan requests through claude.Adaptor (which uses the Claude-specific endpoint at DoubaoCodingPlanClaudeBaseURL), while other requests use openai.Adaptor. This aligns with GetRequestURL logic (lines 248-255) which returns different URLs based on the same condition.


347-353: Core fix looks correct - Claude response handling now matches request routing.

The added condition info.ChannelBaseUrl == DoubaoCodingPlan ensures Claude-specific response handlers (ClaudeStreamHandler/ClaudeHandler) are only invoked when the request was actually sent to a Claude-compatible endpoint. For other Claude-format requests routed through OpenAI-compatible endpoints (line 255), responses correctly fall through to openai.Adaptor.DoResponse (lines 390-392).

This is consistent with:

  • ConvertClaudeRequest branching (lines 43-48)
  • GetRequestURL which returns /api/v3/chat/completions for non-DoubaoCodingPlan Claude requests (line 255)

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.

@Calcium-Ion
Calcium-Ion merged commit a6a20a2 into QuantumNous:main Nov 25, 2025
sususu98 pushed a commit to sususu98/new-api that referenced this pull request Dec 1, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Dec 11, 2025
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
salem-2007 added a commit to salem-2007/new-api that referenced this pull request Sep 10, 2026
junjundesk pushed a commit to junjundesk/new-api that referenced this pull request Oct 3, 2026
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.

2 participants