fix: update Codex executor for gpt-5.3-codex support

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
apple-techie
2026-02-12 18:12:38 +07:00
committed by decolua
co-authored by Cursor
parent 9c9af25acd
commit d7d5dc90bc
5 changed files with 60 additions and 14 deletions
+25 -1
View File
@@ -11,10 +11,27 @@ export class CodexExecutor extends BaseExecutor {
super("codex", PROVIDERS.codex);
}
/**
* Override headers to add session_id per request
*/
buildHeaders(credentials, stream = true) {
const headers = super.buildHeaders(credentials, stream);
headers["session_id"] = `${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
return headers;
}
/**
* Transform request before sending - inject default instructions if missing
*/
transformRequest(model, body, stream, credentials) {
// Ensure input is present and non-empty (Codex API rejects empty input)
if (!body.input || (Array.isArray(body.input) && body.input.length === 0)) {
body.input = [{ type: "message", role: "user", content: [{ type: "input_text", text: "..." }] }];
}
// Ensure streaming is enabled (Codex API requires it)
body.stream = true;
// If no instructions provided, inject default Codex instructions
if (!body.instructions || body.instructions.trim() === "") {
body.instructions = CODEX_DEFAULT_INSTRUCTIONS;
@@ -39,10 +56,17 @@ export class CodexExecutor extends BaseExecutor {
// Priority: explicit reasoning.effort > reasoning_effort param > model suffix > default (medium)
if (!body.reasoning) {
const effort = body.reasoning_effort || modelEffort || 'medium';
body.reasoning = { effort };
body.reasoning = { effort, summary: "auto" };
} else if (!body.reasoning.summary) {
body.reasoning.summary = "auto";
}
delete body.reasoning_effort;
// Include reasoning encrypted content (required by Codex backend for reasoning models)
if (body.reasoning && body.reasoning.effort && body.reasoning.effort !== 'none') {
body.include = ["reasoning.encrypted_content"];
}
// Remove unsupported parameters for Codex API
delete body.temperature;
delete body.top_p;