fix(openai): Enable gpt-5.4 support via Chat Completions fallback on scope error#38026
fix(openai): Enable gpt-5.4 support via Chat Completions fallback on scope error#38026yfge wants to merge 1 commit intoopenclaw:mainfrom
Conversation
Greptile SummaryThis PR adds a targeted fallback mechanism for
Confidence Score: 4/5
Last reviewed commit: 0d9ab6f |
|
Thanks for the review @Takhoffman. I'd like to respectfully push back — I believe this PR addresses a gap that #27501 does not cover. What #27501 does: Adds What it doesn't do: Fix the default behavior. When users configure the What this PR does: Catches the specific Real-world impact I'm seeing right now (OpenClaw 2026.3.2): Every #27501 gives power users a config escape hatch. This PR makes it Just Work™ for everyone. They're complementary, not redundant. Could you please reopen this? |
|
Adding more context on why this PR is still needed — I dug into the source code and found the root cause. Why
|
|
I think it's actually more related to this issue: |
|
Filed a follow-up issue for a legacy-config case that can still leave Codex OAuth broken after upgrade: #40066\n\nIn short: older manual overrides can shadow the built-in Codex OAuth provider even after the fixes in this PR. |
|
Correcting my previous comment formatting: Filed a follow-up issue for a legacy-config case that can still leave Codex OAuth broken after upgrade: #40066 In short: older manual |
Resolves #24927
Problem
Models like
openai-codex/gpt-5.4currently fail with a401 Unauthorizederror when used with an OAuth token (e.g., from the Codex appapp_EMoamEEZ73f0CkXaXp7hrann).This is because OpenClaw defaults to the newer OpenAI Responses API (
/v1/responses), which requires anapi.responses.writescope that is not present in existing OAuth tokens. The current system treats this as a generic authentication error and triggers a model failover, which preventsgpt-5.4from being used as intended.Solution
To provide a seamless experience and enable
gpt-5.4support for users on existing authentication schemes, this PR introduces a more graceful fallback mechanism.When a model using the
openai-responsesAPI fails specifically with a "missing scopes: api.responses.write" error, this change implements a one-time retry. The retry automatically uses theopenai-completionsAPI type for the same model, effectively routing the request to the compatible/v1/chat/completionsendpoint.Key Changes:
isMissingScopeResponsesWrite()precisely identifies the scope-related failure.gpt-5.4without interruption. A warning is logged to inform about the automatic API fallback, maintaining transparency.