fix(openai-codex): support GPT-5.6 Luna Responses Lite#889
Conversation
📝 WalkthroughWalkthroughThe Codex provider now supports GPT-5.6 Luna Responses Lite requests through exact model gating, body transformation, session-aware headers, consistent streaming/fallback handling, and ChangesLuna Responses Lite support
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant OpenAiCodexHandler
participant CodexSDK
participant SSEEndpoint
OpenAiCodexHandler->>OpenAiCodexHandler: Resolve session and transform Luna body
OpenAiCodexHandler->>CodexSDK: Send transformed body and headers
CodexSDK-->>OpenAiCodexHandler: Return stream or fail
OpenAiCodexHandler->>SSEEndpoint: Retry with the same body and headers
SSEEndpoint-->>OpenAiCodexHandler: Return SSE stream
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ 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 |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/api/providers/__tests__/openai-codex.spec.ts (1)
339-339: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueHoist the Luna version string into a shared test constant.
"0.144.0"is repeated in three assertions; centralizing it avoids updating multiple spots when the header version changes.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@src/api/providers/__tests__/openai-codex.spec.ts` at line 339, Define a shared test constant for the Luna version near the other test fixtures in openai-codex.spec.ts, then replace all three hardcoded "0.144.0" assertion values with that constant. Keep the existing assertions and expected version unchanged.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@src/api/providers/__tests__/openai-codex.spec.ts`:
- Line 339: Define a shared test constant for the Luna version near the other
test fixtures in openai-codex.spec.ts, then replace all three hardcoded
"0.144.0" assertion values with that constant. Keep the existing assertions and
expected version unchanged.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: c2922768-3277-4e17-9d7b-91f33bc97186
📒 Files selected for processing (4)
docs/luna-responses-lite-analysis.mdsrc/api/providers/__tests__/openai-codex-native-tool-calls.spec.tssrc/api/providers/__tests__/openai-codex.spec.tssrc/api/providers/openai-codex.ts
|
@zoomote please review this PR |
|
@roomote please review |
Summary and root cause
Zoo Code already catalogs the exact model ID
gpt-5.6-luna, but ChatGPT OAuth requests to that model failed because Luna expects the Responses Lite request contract rather than the normal Responses request used by the OpenAI Codex provider. The standard request body and headers were therefore incompatible with Luna.This change detects only the exact
gpt-5.6-lunamodel on the ChatGPT OAuth Codex path, transforms the outgoing body into the Responses Lite-compatible shape, and adds the Luna-only headers required for routing, affinity, and prompt caching. Non-Luna requests continue using the existing standard Responses contract.The initial request referred to “5.5 Luna.” However, upstream anomalyco/opencode#36685, its corresponding commit, and Zoo Code's existing model catalog identify the model as
gpt-5.6-luna. Exact equality is intentional: this does not change GPT-5.5, Sol, Terra, model aliases, API-key providers, or any other transport.Request handling
For exact-model Luna requests, the provider now:
session-idandx-session-affinityheaders in addition to the existing Codexsession_idheader;prompt_cache_keyso request affinity and prompt caching remain stable;completePrompt, keeping one-shot completion behavior aligned with streaming behavior.flowchart LR subgraph Before[Before] B1[ChatGPT OAuth request] --> B2{Exact model gpt-5.6-luna?} B2 --> B3[Normal Responses body and headers] B3 --> B4[Luna rejects incompatible contract] end subgraph After[After] A1[ChatGPT OAuth request] --> A2{Exact model gpt-5.6-luna?} A2 -- No --> A3[Existing normal Responses path] A2 -- Yes --> A4[Transform to Responses Lite body] A4 --> A5[Add Luna-only session and affinity headers] A5 --> A6[SDK streaming, SSE fallback, auth retry, or completePrompt] A6 --> A7[Luna request succeeds] endtaskIdand provider session boundaryNo core task ID was removed, replaced, regenerated, or mutated.
Before this change, request metadata
taskIdwas already used only inside this provider as the Codexsession_idheader. The provider now resolves that value once into a provider-localeffectiveSessionId, using the handler UUID only as a fallback when request metadata does not supply ataskId. That single provider-local value is then reused consistently for:session_id;session-id;x-session-affinity; andprompt_cache_key.Core task execution, tool dispatch, subtask routing, persistence, and task lookup remain unchanged. The provider consumes core metadata to derive transport metadata; it does not write a provider session value back into core task state.
flowchart LR subgraph Core[Core task domain] T[Existing taskId] E[Task execution] D[Tool and subtask dispatch] P[Persistence and lookup] T --> E T --> D T --> P end subgraph Provider[OpenAI Codex provider boundary] M[Read request metadata taskId] F[Fallback: handler UUID] S[Resolve effectiveSessionId once] H[session_id / session-id / x-session-affinity] C[prompt_cache_key] M --> S F --> S S --> H S --> C end T -- read-only metadata --> M S -. no mutation or write-back .-> TScope and non-goals
gpt-5.6-lunarequests through the ChatGPT OAuth OpenAI Codex provider.Tests and verification
srctype check passed.srclint passed.References
docs/luna-responses-lite-analysis.mdSummary by CodeRabbit
New Features
gpt-5.6-lunamodel through Responses Lite request handling.Documentation
Tests