feat: opt-in Responses Lite request shape for GPT-5.6 models#45
Closed
chrisolszewski wants to merge 1 commit into
Closed
feat: opt-in Responses Lite request shape for GPT-5.6 models#45chrisolszewski wants to merge 1 commit into
chrisolszewski wants to merge 1 commit into
Conversation
Add a `responsesLite` setting (env CORTEXKIT_OPENAI_AUTH_RESPONSES_LITE, default false) that sends gpt-5.6-sol/-terra/-luna requests in Codex's Responses Lite wire shape, matching the Codex CLI. Verified against openai/codex at rust-v0.144.0 (7678224, the version this plugin spoofs) and current main (38b064c3); the Lite contract is identical in both: - use_responses_lite is set via catalog lookup on exactly gpt-5.6-sol, gpt-5.6-terra, gpt-5.6-luna; unknown models default to the normal shape, so eligibility here is an exact set, not a prefix match. - Lite bodies use reasoning.context=all_turns, parallel_tool_calls=false, and move tools/instructions into the input: an additional_tools developer item (client-executed tools only — hosted tools like web_search are excluded, core/src/tools/spec_plan.rs) plus a developer message for non-empty instructions (empty instructions are omitted from the wire). - detail is stripped from every input_image, including images nested in function/custom-tool outputs (core/src/client_common.rs). - Transport marking: HTTP header x-openai-internal-codex-responses-lite; WebSocket uses request-scoped client_metadata (the upgrade is unmarked). The WS→HTTP fallback converts the metadata marker to the header. - Codex prewarms Lite WS sessions normally; prewarm is unchanged. Because Lite carries tools inline, eligible requests bypass the web_search prompt-cache stabilizer, as Codex itself does for these models. Keepwarm replays are Lite-aware: captures keep the HTTP marker header, and WS-captured bodies are converted through the existing WS→HTTP fallback sanitizer before tracking. That conversion also stops pre-existing leakage of the WS-only client_metadata keys (x-codex-turn-metadata, x-codex-ws-stream-request-start-ms) into warm replays for all WS sessions.
Contributor
|
Superseded by the integrated implementation prepared for main. Responses Lite remains default-off, is limited to exact GPT-5.6 Sol/Luna/Terra wire models, preserves the standard request path when disabled, and now handles HTTP, WebSocket, cachekeep, and HTTP fallback marker conversion consistently. Thank you for reporting the repeatable behavior difference and contributing the initial implementation. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Codex sends
gpt-5.6-sol,gpt-5.6-terra, andgpt-5.6-lunarequests in its Responses Lite wire shape (use_responses_litein its model catalog): a different body layout plus a per-transport marker. This plugin always sends the normal Responses shape for those models, so its traffic diverges from what the official CLI emits for exactly the models it spoofs a Codex client for.Fix
Add an opt-in
responsesLitesetting (envCORTEXKIT_OPENAI_AUTH_RESPONSES_LITE, defaultfalse, resolved env → config → default like every other setting). When enabled, requests for the three Lite models are rewritten to Codex's Lite contract; everything else is byte-identical to today.I verified the behavior directly against
openai/codexat rust-v0.144.0 (7678224, the version this plugin spoofs) and currentmain(38b064c3); the contract is identical in both:use_responses_liteby catalog lookup and unknown models default to the normal shape. Basegpt-5.6and hypothetical futuregpt-5.6-*names stay non-Lite. No model-visibility changes.reasoning.context: "all_turns",parallel_tool_calls: false; tools/instructions move intoinputas anadditional_toolsdeveloper item plus a developer message for non-empty instructions (emptyinstructionsis omitted from the wire), per the Lite branch of request assembly. Hosted Responses tools likeweb_searchare excluded from Lite tool specs; only client-executed tools are carried.detailis stripped from everyinput_image, including ones nested in function/custom-tool outputs.x-openai-internal-codex-responses-lite: true; WebSocket carries the request-scopedclient_metadatakey (the upgrade itself is unmarked). The existing WS→HTTP fallback converts the metadata marker into the header. WS prewarm is unchanged; Codex prewarms Lite sessions normally.client_metadatakeys (x-codex-turn-metadata,x-codex-ws-stream-request-start-ms) into warm replays for all WS sessions.Scope / limits
web_searchprompt-cache stabilizer, matching what Codex itself sends for these models. Documented in the settings tables.Testing
bun run build·bun run typecheck·bunx biome check src: all cleanbun test: 576 pass / 0 fail (new: config default/file/env precedence; exact-model + disabled gating; the full eligible-body rewrite including hosted-tool exclusion and nested image-detailstripping; non-Lite preservation; WS metadata marking + prewarm; WS→HTTP fallback marker conversion; keepwarm replay of a WS-captured Lite body arriving as a marked, sanitized HTTP request)Need help on this PR? Tag
/codesmithwith what you need. Autofix is disabled.Summary by cubic
Adds an opt-in Responses Lite request shape for
gpt-5.6-sol,gpt-5.6-terra, andgpt-5.6-luna, matching the Codex CLI. Default is off; enabling it rewrites bodies and marks transport correctly, with improved keepwarm behavior.New Features
responsesLitesetting (envCORTEXKIT_OPENAI_AUTH_RESPONSES_LITE, defaultfalse). When on, only the exact models above use Lite; all others are unchanged.reasoning.context: "all_turns",parallel_tool_calls: false, tools/instructions moved intoinput(hostedweb_searchexcluded), anddetailstripped from allinput_images.x-openai-internal-codex-responses-lite: true; WebSocket sets aclient_metadataflag. WS→HTTP fallback converts the flag into the header. Keepwarm captures/replays preserve the Lite marker.Bug Fixes
client_metadatakeys (x-codex-turn-metadata,x-codex-ws-stream-request-start-ms) into keepwarm HTTP replays.Written for commit adf4564. Summary will update on new commits.