Repository navigation
feat: claude context editing - #1925
Conversation
WalkthroughAdds ContextManagement to ClaudeRequest DTO. Propagates anthropic-beta header in AWS and Claude adaptors during request setup. Updates UI to remove max=1 constraint and adjust helper text. Adds new i18n key "0.1以上的小数" to English and French locales. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant Client as Client
participant Gateway as Relay Adaptor (AWS/Claude)
participant Upstream as Anthropic API
Client->>Gateway: HTTP request<br/>headers: anthropic-version, anthropic-beta?
Note over Gateway: SetupRequestHeader<br/>reads anthropic-beta if present
Gateway->>Upstream: Forwarded request<br/>headers: anthropic-version (+ anthropic-beta if present)
Upstream-->>Gateway: Response
Gateway-->>Client: Response
sequenceDiagram
autonumber
participant UI as Settings UI
participant Store as Config Store
UI->>UI: InputNumber change (no max=1)
UI->>Store: Save BudgetTokens percentage
Note over UI: Helper text uses key "0.1以上的小数" (i18n EN/FR added)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate 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. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
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/Model/SettingClaudeModel.jsx (1)
201-213: Enforce upper bound of 1.0 on BudgetTokens percentage input
No backend validation exists for values >1.0 on thethinking_adapter_budget_tokens_percentagefloat64 field (only the struct is defined in Go), so re-addmax={1}to the InputNumber in web/src/pages/Setting/Model/SettingClaudeModel.jsx (lines 201–213).
🧹 Nitpick comments (2)
relay/channel/claude/adaptor.go (1)
70-73: Consistent anthropic-beta forwarding; confirm header precedenceMatches AWS adaptor. As coded, model_setting.WriteHeaders may overwrite the forwarded beta header. Confirm whether config should override client preference; if not, move Set("anthropic-beta", ...) after WriteHeaders.
To ensure consistency everywhere:
- req.Set("anthropic-version", anthropicVersion) - anthropicBeta := c.Request.Header.Get("anthropic-beta") - if anthropicBeta != "" { req.Set("anthropic-beta", anthropicBeta) } - model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req) + req.Set("anthropic-version", anthropicVersion) + model_setting.GetClaudeSettings().WriteHeaders(info.OriginModelName, req) + if v := c.Request.Header.Get("anthropic-beta"); v != "" { req.Set("anthropic-beta", v) }web/src/i18n/locales/en.json (1)
1407-1407: Clarify inclusive boundary in helper textThe key
"0.1以上的小数"currently reads"Decimal above 0.1", which implies >0.1 but the Chinese means ≥0.1. Update to:- "0.1以上的小数": "Decimal above 0.1", + "0.1以上的小数": "Decimal ≥ 0.1",Verify that the UI input validation enforces a minimum of 0.1.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (6)
dto/claude.go(1 hunks)relay/channel/aws/adaptor.go(1 hunks)relay/channel/claude/adaptor.go(1 hunks)web/src/i18n/locales/en.json(1 hunks)web/src/i18n/locales/fr.json(1 hunks)web/src/pages/Setting/Model/SettingClaudeModel.jsx(1 hunks)
🔇 Additional comments (3)
relay/channel/aws/adaptor.go (1)
55-58: Confirm anthropic-beta header precedence
In both relay/channel/aws/adaptor.go (lines 55–58) and relay/channel/claude/adaptor.go (70–73), you propagate anthropic-beta before calling model_setting.WriteHeaders, which allows site-level config to overwrite the client’s header. If client-provided headers should take precedence, move this block below WriteHeaders in each adaptor. (Optional) Centralize anthropic-beta forwarding across adaptors to avoid duplication.dto/claude.go (1)
199-204: All confirmed: no BC issues with ContextManagementBoth
dto.ClaudeRequestliterals in relay/channel/claude/relay-claude.go use fully keyed fields (no positional literals), so addingContextManagementwon’t break existing code. The override logic (ApplyParamOverride) unmarshals into a generic map and re-serializes, preserving any fields (includingcontext_management).web/src/pages/Setting/Model/SettingClaudeModel.jsx (1)
205-205: LGTM! Good i18n improvement.The change to use a translated key for the helper text improves internationalization support.
| "Claude思考适配 BudgetTokens = MaxTokens * BudgetTokens 百分比": "Adaptation de la pensée Claude BudgetTokens = MaxTokens * BudgetTokens pourcentage", | ||
| "思考适配 BudgetTokens 百分比": "Adaptation de la pensée BudgetTokens pourcentage", | ||
| "0.1-1之间的小数": "Décimal entre 0,1 et 1", | ||
| "0.1以上的小数": "Décimal supérieur à 0,1", |
There was a problem hiding this comment.
Correction: inclusive boundary in FR
Use “supérieur ou égal à 0,1” to reflect ≥.
- "0.1以上的小数": "Décimal supérieur à 0,1",
+ "0.1以上的小数": "Décimal supérieur ou égal à 0,1",📝 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.
| "0.1以上的小数": "Décimal supérieur à 0,1", | |
| "0.1以上的小数": "Décimal supérieur ou égal à 0,1", |
🤖 Prompt for AI Agents
In web/src/i18n/locales/fr.json around line 1407, the French translation
currently reads "Décimal supérieur à 0,1" but should reflect an inclusive
boundary (≥); update the value to "Décimal supérieur ou égal à 0,1" to match the
intended meaning while preserving surrounding JSON formatting and quoting.
…ext-editing feat: claude context editing
…ext-editing feat: claude context editing
…ext-editing feat: claude context editing
Summary by CodeRabbit
New Features
Chores