fix(codex): allow image_generation tool advertisement on backend responses path#439
fix(codex): allow image_generation tool advertisement on backend responses path#439ihazgithub wants to merge 2 commits intoSoju06:mainfrom
Conversation
Context / reviewer noteI wanted to add a little plain-English context for why I dug into this path. This change came from a real compatibility problem I hit while using Codex through
I captured and inspected the actual client payload and found that it validated cleanly except for one top-level tool advertisement:
Everything else in the same payload that mattered for my workflow was still valid, including the client's That is why this PR is intentionally narrow. Rather than changing the global unsupported-tool policy, it only strips that top-level So the goal here is not to broaden tool support generally. The goal is to restore backend Codex client compatibility for the real payload being sent today, while keeping the shared public validation behavior as strict as it was before. I also validated the fix against the real captured payload after the change: it now normalizes successfully with the expected tools preserved and only the blocking top-level |
|
Follow-up fix for the backend HTTP regression in the first version of this PR. The initial compatibility change unintentionally changed That caused payloads with missing required fields like This follow-up keeps the narrow |
|
Local validation update:
One small ops note: the image still exposes |
Summary
Current Codex clients advertise a top-level
image_generationtool on/backend-api/codex/responsesrequests, for example:{"type":"image_generation","output_format":"png"}codex-lb currently routes backend Codex Responses payloads through shared request validation, which rejects that tool and surfaces:
Invalid request payload, param: "tools"This change keeps the fix narrow and backend-Codex-specific. It strips only that top-level
image_generationadvertisement on the backend Codex responses path before shared validation, while leaving public/v1/*validation unchanged.What Changed
/backend-api/codex/responses/backend-api/codex/responsesresponse.createhandling/v1/*/v1/responsesrejection behaviorScope
This change does not:
image_generationfrom the global unsupported tool list/v1/responsesvalidation/v1/chat/completionsbehaviorIt affects only top-level backend-Codex
toolsentries and preserves other advertised tools such asfunction,custom,web_search, andnamespace.Validation
Focused coverage added or updated:
test_normalize_responses_request_payload_strips_backend_codex_image_generation_toolstest_normalize_responses_request_payload_without_codex_compat_still_rejects_image_generationtest_backend_responses_strip_image_generation_tool_advertisementtest_backend_responses_websocket_strips_image_generation_tool_advertisementtest_v1_responses_rejects_builtin_toolsnow also pinsparam == "tools"Commands run:
.venv/bin/python -m pytest tests/unit/test_proxy_utils.py -k "normalize_responses_request_payload".venv/bin/python -m pytest tests/integration/test_openai_compat_features.py -k "test_v1_responses_rejects_builtin_tools or test_backend_responses_allows_web_search or test_backend_responses_strip_image_generation_tool_advertisement".venv/bin/python -m pytest tests/integration/test_proxy_websocket_responses.py -k "test_backend_responses_websocket_proxies_upstream_and_persists_log or test_backend_responses_websocket_strips_image_generation_tool_advertisement"openspec validate --specsI also re-validated the real captured Codex payload that originally failed; it now normalizes successfully while preserving the client’s
function,custom,web_search, andnamespacetools.