fix(openai-codex): honor providerConfig.baseUrl in dynamic-model synthesis fallback#76428
Conversation
…hesis fallback The synthesis fallback in resolveCodexForwardCompatModel hardcoded OPENAI_CODEX_BASE_URL when the model registry had no template row to clone, which meant openai-codex providers configured with a custom baseUrl (e.g. a local proxy that forwards Codex traffic) silently fell back to api.openai.com / chatgpt.com - bypassing the proxy and typically failing the auth contract. Synthesis now reads ctx.providerConfig.baseUrl when present, with the existing OPENAI_CODEX_BASE_URL constant as the fallback. No effect on template-clone or registry-find paths, which already inherit the configured baseUrl through the cloned template.
|
Codex review: needs maintainer review before merge. Summary Reproducibility: yes. for the hook-level issue: call the OpenAI Codex provider dynamic-model hook with an empty/no-template registry and Next step before merge Security Review detailsBest possible solution: Merge the narrow provider-hook fix after normal CI; add an embedded-runner regression only if maintainers want explicit proof for the reported end-to-end routing path. Do we have a high-confidence way to reproduce the issue? Yes for the hook-level issue: call the OpenAI Codex provider dynamic-model hook with an empty/no-template registry and Is this the best way to solve the issue? Yes. Reading What I checked:
Likely related people:
Remaining risk / open question:
Codex review notes: model gpt-5.5, reasoning high; reviewed against b258c3fc6578. |
…synthesis baseUrl honor
|
Added the missing Unreleased Fixes entry per the Codex review (a67d996). |
|
@arniesaha perfect PR, zero fixes needed. Straight merge ;) |
…hesis fallback (openclaw#76428) * fix(openai-codex): honor providerConfig.baseUrl in dynamic-model synthesis fallback The synthesis fallback in resolveCodexForwardCompatModel hardcoded OPENAI_CODEX_BASE_URL when the model registry had no template row to clone, which meant openai-codex providers configured with a custom baseUrl (e.g. a local proxy that forwards Codex traffic) silently fell back to api.openai.com / chatgpt.com - bypassing the proxy and typically failing the auth contract. Synthesis now reads ctx.providerConfig.baseUrl when present, with the existing OPENAI_CODEX_BASE_URL constant as the fallback. No effect on template-clone or registry-find paths, which already inherit the configured baseUrl through the cloned template. * docs(changelog): add Unreleased Fixes entry for openclaw#76428 codex synthesis baseUrl honor
…hesis fallback (openclaw#76428) * fix(openai-codex): honor providerConfig.baseUrl in dynamic-model synthesis fallback The synthesis fallback in resolveCodexForwardCompatModel hardcoded OPENAI_CODEX_BASE_URL when the model registry had no template row to clone, which meant openai-codex providers configured with a custom baseUrl (e.g. a local proxy that forwards Codex traffic) silently fell back to api.openai.com / chatgpt.com - bypassing the proxy and typically failing the auth contract. Synthesis now reads ctx.providerConfig.baseUrl when present, with the existing OPENAI_CODEX_BASE_URL constant as the fallback. No effect on template-clone or registry-find paths, which already inherit the configured baseUrl through the cloned template. * docs(changelog): add Unreleased Fixes entry for openclaw#76428 codex synthesis baseUrl honor
Summary
When the
openai-codexprovider is configured with a custombaseUrl(e.g. a local proxy that forwards Codex traffic) and the model registry has no template row to clone for the requested id,resolveCodexForwardCompatModelsynthesizes aProviderRuntimeModelwith a hardcodedOPENAI_CODEX_BASE_URL. The configured proxy URL is silently dropped, traffic goes tochatgpt.com/api.openai.comdirectly, and the call typically fails the auth contract — without anymodel.attemptevent reaching the user (since the failure happens beforesession.started).Fix
resolveCodexForwardCompatModelnow readsctx.providerConfig?.baseUrland uses it as the synthesis baseUrl when present, falling back toOPENAI_CODEX_BASE_URLwhen not. This affects both synthesis fallbacks in the function (the gpt-5.5 path and the gpt-5.4/pro/mini/legacy path).The template-clone (
cloneFirstTemplateModel) and registry-find (ctx.modelRegistry.find) paths are unchanged — they already inherit the configuredbaseUrlthrough the cloned/found model. This is the smallest fix that closes the silent-bypass behavior without touching catalog or transport normalization.Why now
Reproduced on a real deployment: a custom
~/.openclaw/agents/<id>/agent/models.jsonwithproviders["openai-codex"].baseUrl = "http://192.168.1.70:30400"andmodels = []. With this config the gateway silently routed every call to chatgpt.com instead of the proxy, then fell back to a different provider after the codex attempt failed — with no observable trajectory event explaining why. After the patch, traffic flows through the configured proxy as expected.Test plan
openai-codex-provider.test.ts:honors providerConfig.baseUrl in the gpt-5.5 synthesis fallbackhonors providerConfig.baseUrl in the gpt-5.4 synthesis fallbackpnpm tsgo:extensionsclean.pnpm lintclean (extensions + core + scripts shards).pnpm exec oxfmt --checkclean.pnpm check:import-cyclesclean.POST /codex/responses 200 OKnow lands at the configured proxy.🤖 Generated with Claude Code