Fix ChatGPT Codex requests and post-tool retries - #563
Conversation
| :reason? (:discovered-reason? model-config) | ||
| :api (:discovered-api model-config) | ||
| :variants (:discovered-variants model-config) | ||
| :codex-responses-lite? (:discovered-codex-responses-lite? model-config) |
There was a problem hiding this comment.
I don't like this specific flag for a llm provider, we should have this agnostic like all other keys
| (lifecycle/maybe-renew-auth-token chat-ctx) | ||
| (get-in @db* [:auth provider])) | ||
| :variant (:variant chat-ctx) | ||
| :chat-id chat-id |
There was a problem hiding this comment.
is this really needed? llm-api should be agnostic of chats and ids ideally
|
@itkonen I fixed it in master in a different way to avoid some code coupling + small concerns I had, I think next time is good for us to start with a issue before the PR, but thank you for the problem report and details! |
Co-authored-by: Juha Itkonen <itkonen.juha@gmail.com>
|
@ericdallo Yes, I agree. This was sort of a hotfix that ended up having a wider impact than I would have liked. The Codex OAuth provider had essentially stopped working in ECA, and I needed a solution fast. The were multiple design choices that would have merited discussion, if it weren't for the urgency. |
Recently Codex had become practically unusable with constant overload errors. It turned out, the problem was in the way ECA handled Responses API, as the API behaviour had evolved. The constant errors also revealed a gap in how the harness handled errors/retries after tool calls, causing the session to stop on transient errors. This was especially problematic for subagents, which could never finish if such an error occured. This PR should fix all these problems. Initial testing indicates that Codex sessions now run problem free.
Summary
Root cause
ECA sent the Codex
Originatorheader without a matching versionedUser-Agent. The ChatGPT Codex backend reported this invalid request identity asserver_is_overloaded, so retries could not recover.Requests now use Codex's paired default identity:
Originator: codex_cli_rsUser-Agent: codex_cli_rs/0.146.0GPT-5.6 Codex models additionally use the Responses Lite payload shape, stable session and thread identifiers, and
x-codex-turn-statecontinuation. Instructions are sent exactly once: as top-levelinstructionsfor regular Responses requests, or as a developer input message for Responses Lite.Retry behavior
The existing outer retry controller cannot safely restart a turn after a tool has executed. OpenAI Responses continuations can now retry only the failed HTTP request while it remains replay-safe, preserving completed tool results. Duplicate terminal errors from stacked continuation requests are also suppressed.
Provider safety
The Codex request profile is selected only for the built-in
openaiprovider using ChatGPT OAuth. API-key OpenAI, Copilot, custom Responses providers, and other providers retain their existing request formats. Responses Lite moves function tools intoadditional_tools; regular Responses requests continue to preserve hosted web and image tools.Validation
bb test: 853 tests, 4,734 assertions, 0 failuresFocused OpenAI provider tests: 35 tests, 156 assertions, 0 failures
Integration tests: 5 tests, 93 assertions, 0 failures
Touched-file lint: 0 errors, 0 warnings
Full lint: 0 errors; 10 pre-existing protocol warnings
bb prod-cliLive ChatGPT OAuth request with the rebuilt executable and
gpt-5.6-sol: returnedOK, generated a title, exposed function tools, and produced no overload or transport errorsI added a entry in changelog under unreleased section.
This is not an AI slop.