fix(claude): preserve usable Go session affinity across translation - #3961
Conversation
Co-authored-by: GPT-6 Astra <noreply@openai.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com> (cherry picked from commit a2909be)
Count explicit OpenCode session identity only when the downstream normalizer accepts it, allowing valid metadata fallback. Require usable metadata for Go synthesis on both Chat and Responses wires while preserving native ChatGPT synthesis. Add final-outbound contract cases for invalid and oversized headers, absent and unusable metadata, and explicit lane/operator precedence using independent fixed vectors. Local tests, typecheck, build, install, and runtime checks: NOT RUN by user instruction; patch self-inspected with Git/source/diff only. Source-commit: a2909be Co-authored-by: David Wang <72378768+david-wang-0@users.noreply.github.com> Co-authored-by: GPT-6 Astra <noreply@openai.com> Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughThe Claude Messages path now recognizes canonical OpenCode Go destinations, forwards explicit session headers, and synthesizes session affinity from Claude metadata. Tests cover routing, precedence, fallback behavior, wire selection, streaming responses, and custom destinations. ChangesClaude OpenCode Go session affinity
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant ClaudeClient
participant ClaudeMessages
participant ProviderRegistry
participant OpenCodeGo
ClaudeClient->>ClaudeMessages: POST /v1/messages with metadata and optional session header
ClaudeMessages->>ProviderRegistry: resolve routed destination
ProviderRegistry-->>ClaudeMessages: identify canonical opencode-go route
ClaudeMessages->>ClaudeMessages: preserve or synthesize session identity
ClaudeMessages->>OpenCodeGo: send chat completion with session headers
OpenCodeGo-->>ClaudeMessages: return JSON or SSE response
ClaudeMessages-->>ClaudeClient: return Claude Messages response
Suggested reviewers: ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
|
✅ Deterministic PR hygiene checks passed. |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
리뷰 · 우선순위 71 / 80이 PR은 Claude Code가 패치 요지는 세 겹입니다. (1) 테스트 라인 src/server/claude-messages.ts · opencodeGoRoute - destination registry id로 판별하므로 lookalike URL을 Go로 오인하지 않습니다. 커스텀 Go 호환 엔드포인트를 쓰는 사용자는 이 게이트 밖입니다. 그게 의도인지 한 번만 확인하면 됩니다. 라인 src/server/claude-messages.ts · synthesizeGoSession / hasExplicitGoSession - 경로 draft + CI - 머지 전에 undraft와 hosted CI 그린이 전제입니다. #3945는 이미 CLOSED 상태이므로, 머지 시 이슈 상태보다 PR close/landing 코멘트가 중요합니다. 메인테이너의 판단이 필요한 지점
너의 추천 이 댓글은 grok-bot이 작성했습니다 |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ac8010db91
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const route = routeModel(config, internalBody.model as string, evidenceFromBody(internalBody)); | ||
| // Match the fixed key-auth destination before per-model wire overrides, including | ||
| // renamed Go providers without treating custom or lookalike URLs as Go. | ||
| opencodeGoRoute = registryEntryForProviderDestination(route.provider)?.id === "opencode-go"; |
There was a problem hiding this comment.
Derive Go affinity from the final combo target
When a Claude request names a combo using the random strategy, this preflight routeModel call and handleComboResponses' separate pick at src/server/responses/core.ts:2618 can select different targets. If preflight selects a non-Go key provider but dispatch selects OpenCode Go, opencodeGoRoute remains false and no metadata-derived session lane is added, so Go affinity is intermittently lost. Carry the validated metadata identity through the replay and apply it after the combo/fallback target is finalized, and add a combo regression case.
Useful? React with 👍 / 👎.
Carry validated Claude affinity privately through combo replay and consume it only at the final canonical Go transport. Preserve explicit identity and operator precedence without leaking Go-only headers to other destinations. Addresses the late review on lidge-jun#3961. Adds deterministic random and failover regressions across both Go wires. Co-authored-by: GPT-6 Astra <noreply@openai.com>
Summary
Preserve Claude Messages conversation affinity when the selected destination is canonical OpenCode Go, including renamed providers and model-specific wire overrides. Carry #3949 and retain David Wang's authorship.
Forward usable explicit Go session identity and use the existing metadata-derived fallback only when no usable explicit lane exists. Reject empty/unusable metadata for newly synthesized Go affinity. Preserve configured operator-header precedence and native Anthropic/ChatGPT behavior. Regression cases exercise the real outbound Chat and Responses paths with isolated fixtures.
Closes #3945.
Verification
session_idpresence guard; corrected only Go synthesis, added both-wire regressions and passed interdiff re-review onac8010db910ed598770e05f454e552a3865f54e4.Checklist
Co-authored-by: David Wang 72378768+david-wang-0@users.noreply.github.com
Owner-authorized maintainer integration into dev after independent source/security review and current-head hosted CI. One bug per PR and squash commit; preserve David Wang and the original source trailers.
Pre-merge base refresh: eb4188a adds only #3962, capturing one already-stored fixture JWT instead of regenerating it across a second boundary. No production source, Go tests, shared fixture environment, dependencies or workflow changed. Existing candidate CI remains exact-head evidence; the final combination with this independent test correction is not claimed to have executed before merge. The whole landed tree will be compared with the merge calculation.
Summary by CodeRabbit