Skip to content

feat:default enable channel affinity - #2809

Merged
Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/default-enable-channel-affinity
Feb 2, 2026
Merged

Calcium-Ion merged 1 commit into
QuantumNous:mainfrom
seefs001:feature/default-enable-channel-affinity

Conversation

@seefs001

@seefs001 seefs001 commented Feb 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary by CodeRabbit

  • New Features

    • Enabled channel affinity with two new trace rules: one for GPT models and one for Claude models, each with specific configuration options.
  • Updates

    • Updated rule display labels to reflect new trace naming convention.

@coderabbitai

coderabbitai Bot commented Feb 2, 2026 •

Copy link
Copy Markdown
Contributor

Walkthrough

The pull request enables channel affinity functionality and adds two tracing rules for code model routing. The backend configuration now includes active rules matching GPT and Claude models to specific API endpoints with custom data extraction patterns. Frontend UI labels are updated to reflect these changes.

Changes

Cohort / File(s) Summary
Channel Affinity Configuration
setting/operation_setting/channel_affinity_setting.go
Enabled channel affinity functionality and added two ChannelAffinityRule entries: "codex trace" for gpt-.\* models routing to /v1/responses with prompt_cache_key extraction, and "claude code trace" for claude-.\* models routing to /v1/messages with metadata.user_id extraction. Both rules include group and rule name tracking.
Channel Affinity UI Labels
web/src/pages/Setting/Operation/SettingsChannelAffinity.jsx
Updated rule template display names: "codex优选" → "codex trace" and "claude-code优选" → "claude-code trace" to align with backend configuration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Affinity rules now trace the way,
Codex and Claude both have their say,
With patterns matched and data flows,
Through /v1 endpoints, the tracer goes,
Labels aligned from back to fore,
The tracing paths are now in store! ✨

🚥 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 'feat: default enable channel affinity' is clear and directly describes the main change—enabling channel affinity by default. It accurately reflects the primary modification across both files.

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

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/pages/Setting/Operation/SettingsChannelAffinity.jsx (1)

68-82: ⚠️ Potential issue | 🟡 Minor

Align template name with backend default to avoid duplicate rules.

Line 81 uses claude-code trace, but the backend default rule name is claude code trace. This causes the template appender to treat the default as a different rule name and add a near-duplicate. Pick one spelling and keep both sides consistent.

✅ Suggested fix (match backend default)
-    name: 'claude-code trace',
+    name: 'claude code trace',

@Calcium-Ion
Calcium-Ion merged commit afa9efa into QuantumNous:main Feb 2, 2026
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