Skip to content

feat(claude): add cache_control and speed passthrough controls#4247

Merged
Calcium-Ion merged 1 commit intoQuantumNous:mainfrom
seefs001:feature/missing-fields-260414
Apr 15, 2026
Merged

feat(claude): add cache_control and speed passthrough controls#4247
Calcium-Ion merged 1 commit intoQuantumNous:mainfrom
seefs001:feature/missing-fields-260414

Conversation

@seefs001
Copy link
Copy Markdown
Collaborator

@seefs001 seefs001 commented Apr 14, 2026

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

claude原生请求体填补cache_control和speed,speed增加字段控制,默认过滤

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

  • Closes # (如有)

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

Summary by CodeRabbit

Release Notes

  • New Features
    • Added configurable speed setting for Claude inference (standard vs. fast modes) with optional pass-through control in channel settings
    • Extended Claude request configuration with new optional parameters
    • Added "none" option to tool choice parameter
    • Implemented full multilingual support for new Claude configuration controls

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

Walkthrough

This pull request adds support for the speed field in Claude API requests with optional channel-level pass-through control. It extends the OpenAPI schema with new Claude request properties, adds channel settings to gate speed field transmission, updates request DTOs, implements filtering logic, and provides UI and internationalization support across multiple languages.

Changes

Cohort / File(s) Summary
OpenAPI Schema
docs/openapi/relay.json
Updated ClaudeRequest schema: added "none" to tool_choice enum; added optional properties including cache_control, inference_geo, context_management, output_config, output_format, container, mcp_servers, speed (enum: "standard", "fast"), and service_tier (enum: "auto", "standard_only").
Backend DTOs
dto/channel_settings.go, dto/claude.go
Extended ChannelOtherSettings with AllowSpeed bool field for opt-in speed pass-through; added CacheControl and Speed json.RawMessage fields to ClaudeRequest.
Backend Filtering Logic
relay/common/override.go, relay/common/relay_info.go
Added "speed" to param-override audit paths; extended RemoveDisabledFields to filter out top-level speed field by default unless AllowSpeed is enabled.
Backend Tests
relay/common/override_test.go
Updated TestRemoveDisabledFieldsDefaultFiltering to reflect speed and cache_control preservation; added new TestRemoveDisabledFieldsAllowSpeed test case.
Frontend UI
web/src/components/table/channels/modals/EditChannelModal.jsx
Wired allow_speed field through Claude channel edit/create lifecycle: initialization, loading from settings, persistence, and payload cleanup.
Internationalization
web/src/i18n/locales/en.json, web/src/i18n/locales/fr.json, web/src/i18n/locales/ja.json, web/src/i18n/locales/ru.json, web/src/i18n/locales/vi.json, web/src/i18n/locales/zh-CN.json, web/src/i18n/locales/zh-TW.json
Added translations for speed field description and "Allow speed pass-through" control label across all supported languages.

Possibly related PRs

Poem

🐰 A hop, skip, and speed through the relay,
Fields flow faster when allowed their way,
With controls and translations in place,
Claude's inference picks up the pace! 🚀

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 and specifically describes the main changes: adding support for cache_control and speed passthrough controls for Claude requests.

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

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

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ast-grep (0.42.1)
web/src/components/table/channels/modals/EditChannelModal.jsx

[]


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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
docs/openapi/relay.json (1)

3284-3287: Prefer concrete schemas over empty object placeholders.

The new object fields are currently too generic (properties: {}), which weakens generated SDK typing and API docs quality.

Proposed schema-tightening direction
- "cache_control": {
-   "type": "object",
-   "properties": {}
- },
+ "cache_control": {
+   "$ref": "#/components/schemas/ClaudeCacheControl"
+ },

- "context_management": {
-   "type": "object",
-   "properties": {}
- },
+ "context_management": {
+   "$ref": "#/components/schemas/ClaudeContextManagement"
+ },

- "mcp_servers": {
-   "type": "array",
-   "items": {
-     "type": "object",
-     "properties": {}
-   }
- },
+ "mcp_servers": {
+   "type": "array",
+   "items": {
+     "$ref": "#/components/schemas/ClaudeMcpServer"
+   }
+ },

Also applies to: 3369-3398

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/openapi/relay.json` around lines 3284 - 3287, The OpenAPI schemas use
empty object placeholders (e.g., the "cache_control" schema with "properties:
{}" and other object schemas at the 3369-3398 range), which produces weak
typings; replace those empty-object definitions with concrete property
definitions (list the actual fields expected on cache_control, their types and
required flags) or, if the structure is genuinely free-form, add
"additionalProperties": { "type": "string" } or an explicit
"additionalProperties": false to make intent clear; update the schema entries
(referencing "cache_control" and the other object schema names in that range) so
generated SDKs/docs get accurate types rather than empty objects.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@web/src/i18n/locales/ru.json`:
- Line 581: The Russian translation for the key "允许 speed 透传" uses "Разрешить
передачу speed" but should match adjacent entries' terminology by using
"сквозную передачу"; update the value to "Разрешить сквозную передачу speed" (or
the project-standard phrasing with "сквозную передачу") so the wording is
consistent across ru.json and the UI.

---

Nitpick comments:
In `@docs/openapi/relay.json`:
- Around line 3284-3287: The OpenAPI schemas use empty object placeholders
(e.g., the "cache_control" schema with "properties: {}" and other object schemas
at the 3369-3398 range), which produces weak typings; replace those empty-object
definitions with concrete property definitions (list the actual fields expected
on cache_control, their types and required flags) or, if the structure is
genuinely free-form, add "additionalProperties": { "type": "string" } or an
explicit "additionalProperties": false to make intent clear; update the schema
entries (referencing "cache_control" and the other object schema names in that
range) so generated SDKs/docs get accurate types rather than empty objects.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4144d66-9f5b-42c2-84e5-ec19be3bc2f3

📥 Commits

Reviewing files that changed from the base of the PR and between 8c8661d and 1887af1.

📒 Files selected for processing (14)
  • docs/openapi/relay.json
  • dto/channel_settings.go
  • dto/claude.go
  • relay/common/override.go
  • relay/common/override_test.go
  • relay/common/relay_info.go
  • web/src/components/table/channels/modals/EditChannelModal.jsx
  • web/src/i18n/locales/en.json
  • web/src/i18n/locales/fr.json
  • web/src/i18n/locales/ja.json
  • web/src/i18n/locales/ru.json
  • web/src/i18n/locales/vi.json
  • web/src/i18n/locales/zh-CN.json
  • web/src/i18n/locales/zh-TW.json

"允许 inference_geo 透传": "Разрешить передачу inference_geo",
"允许 safety_identifier 透传": "Разрешить сквозную передачу safety_identifier",
"允许 service_tier 透传": "Разрешить сквозную передачу service_tier",
"允许 speed 透传": "Разрешить передачу speed",
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.

⚠️ Potential issue | 🟡 Minor

Use consistent “透传” wording in Russian translation.

Line 581 currently uses “передачу”, while adjacent entries use “сквозную передачу”. Aligning terminology will keep the UI consistent.

💡 Suggested wording update
-    "允许 speed 透传": "Разрешить передачу speed",
+    "允许 speed 透传": "Разрешить сквозную передачу speed",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"允许 speed 透传": "Разрешить передачу speed",
"允许 speed 透传": "Разрешить сквозную передачу speed",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@web/src/i18n/locales/ru.json` at line 581, The Russian translation for the
key "允许 speed 透传" uses "Разрешить передачу speed" but should match adjacent
entries' terminology by using "сквозную передачу"; update the value to
"Разрешить сквозную передачу speed" (or the project-standard phrasing with
"сквозную передачу") so the wording is consistent across ru.json and the UI.

@Calcium-Ion Calcium-Ion merged commit f7adf02 into QuantumNous:main Apr 15, 2026
2 checks passed
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