feat(codex): add GPT 5.3, fix API translation, add thinking levels

- Add GPT 5.3 Codex model with thinking level variants (none/low/medium/high/xhigh)
- Extract thinking level from model name suffix (e.g., gpt-5.3-codex-high)
- Fix Codex translation: preserve openai-responses format for Droid CLI
- Add effort level logging in request logs

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Hellodebasishsahu
2026-02-06 09:44:41 +07:00
committed by decolua
parent a7a52be2d4
commit 127475df84
4 changed files with 47 additions and 11 deletions

View File

@@ -468,16 +468,22 @@ export async function handleChatCore({ body, modelInfo, credentials, log, onCred
// Create transform stream with logger for streaming response
let transformStream;
// For Codex provider, always translate response from openai-responses to openai format
// This ensures clients like Cursor get the expected chat completions format
// BUT: skip translation if client already sent in openai-responses format (like Droid CLI)
const needsCodexTranslation = (provider === 'codex' || provider === 'openai') && targetFormat === 'openai-responses' && sourceFormat !== 'openai-responses';
if (needsCodexTranslation || needsTranslation(targetFormat, sourceFormat)) {
// For Codex, translate FROM openai-responses TO openai (client's expected format)
const responseSourceFormat = needsCodexTranslation ? 'openai-responses' : targetFormat;
const responseTargetFormat = needsCodexTranslation ? 'openai' : sourceFormat;
transformStream = createSSETransformStreamWithLogger(responseSourceFormat, responseTargetFormat, provider, reqLogger, toolNameMap, model, connectionId, body);
// For Codex provider, translate response from openai-responses to openai (Chat Completions) format
// UNLESS client originally sent in openai-responses format (like Droid CLI) - they expect same format back
const needsCodexTranslation = provider === 'codex'
&& targetFormat === 'openai-responses'
&& sourceFormat !== 'openai-responses';
if (needsCodexTranslation) {
// Codex returns openai-responses, translate to openai (Chat Completions) that clients expect
log?.debug?.("STREAM", `Codex translation mode: openai-responses → openai`);
transformStream = createSSETransformStreamWithLogger('openai-responses', 'openai', provider, reqLogger, toolNameMap, model, connectionId, body);
} else if (needsTranslation(targetFormat, sourceFormat)) {
// Standard translation for other providers
log?.debug?.("STREAM", `Translation mode: ${targetFormat} → ${sourceFormat}`);
transformStream = createSSETransformStreamWithLogger(targetFormat, sourceFormat, provider, reqLogger, toolNameMap, model, connectionId, body);
} else {
log?.debug?.("STREAM", `Standard passthrough mode`);
transformStream = createPassthroughStreamWithLogger(provider, reqLogger, model, connectionId, body);
}