fix(ai): Codex backend request body matches OpenAI Responses schema

After v1.4.9 the OAuth connect went green, but every real insight
call still failed with:

  Codex request failed (400): { "detail": "Input must be a list" }

The `chatgpt.com/backend-api/codex/responses` endpoint speaks the
OpenAI Responses API shape (`ResponsesApiRequest` in
`codex-rs/codex-api/src/common.rs`), where `input` is a list of typed
message items rather than a single string. CodexClient was sending
the older Chat-Completions-style body (`input: <string>`) which the
upstream rejects with the 400 above.

The body now mirrors the canonical shape:

  {
    "model": "gpt-5.3-codex",
    "instructions": "<system prompt>",
    "input": [
      { "type": "message", "role": "user",
        "content": [{ "type": "input_text", "text": "<user prompt>" }] }
    ],
    "tools": [], "tool_choice": "auto",
    "parallel_tool_calls": false, "store": false, "stream": false
  }

The response shape (Output `ResponseItem[]` with `output_text`
content) is unchanged, so `parseResponse` still works without
modification. Both Settings → KI "Verbindung testen" and the insight
generator now complete end-to-end through the ChatGPT subscription.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
Marc-André BombeckandClaude Opus 4.7 committed 2026-05-09 13:34:12 +02:00
1 parent 3dbc8af627
commit 68e5797e48
3 files changed
+33 -2

No files matched your search

+15 -1
View File
@@ -69,6 +69,10 @@ export class CodexClient implements AIProvider {
}
private async doRequest(params: CompletionParams): Promise<Response> {
// The chatgpt.com/backend-api/codex/responses endpoint expects the
// OpenAI Responses API shape: `input` is an array of typed message
// items, NOT a raw string. The Codex CLI's `ResponsesApiRequest`
// (`codex-rs/codex-api/src/common.rs`) is the canonical definition.
return fetch(CODEX_ENDPOINT, {
method: "POST",
headers: {
@@ -78,7 +82,17 @@ export class CodexClient implements AIProvider {
body: JSON.stringify({
model: CODEX_MODEL,
instructions: params.systemPrompt,
input: params.userPrompt,
input: [
{
type: "message",
role: "user",
content: [{ type: "input_text", text: params.userPrompt }],
},
],
tools: [],
tool_choice: "auto",
parallel_tool_calls: false,
store: false,
stream: false,
}),
});