fix: complete Responses image generation calls with results#596
fix: complete Responses image generation calls with results#596SantaDiegoKairos wants to merge 2 commits into
Conversation
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
|
The judgment is too simplistic and does not cover all scenarios. |
7b6576b to
10c9751
Compare
|
Thanks, agreed — the previous check was too broad. I updated the branch to make the normalization terminal-context/status-aware instead of inferring completion from Now it only marks |
|
If this situation only occurs in codex, as a special case, it should be modified within the relevant method in codex, rather than being applied globally. |
|
Thanks — I re-checked the scope more carefully. I don’t think this is only a Codex client/UI rendering issue. In our production deployment we currently have a small local normalizer, so the public HTTP endpoint already returns the corrected shape. With that local fix enabled, image generation works correctly for clients: the image result is present and the terminal To avoid that local fix masking the original behavior, I ran a clean probe that bypasses the final HTTP response normalizer and inspects the raw adapter/converter result. The same terminal mismatch was observed from two different agent environments:
Historical session evidence showed:
A clean direct adapter/converter probe from the Factory AI environment reproduced the same shape, without going through our final normalizer. Non-stream:
Stream:
No production files were edited and the container was not restarted during this verification. The probe was only used to inspect the raw result before our local final-response normalization. So my current understanding is:
It may still be specific to the underlying model / Responses image-generation route we are using, but based on this check it does not appear to be specific to one agent/client. I also updated the implementation after your earlier feedback. It no longer treats any non-empty
And it preserves explicit non-success terminal statuses:
If you still prefer this to be scoped more narrowly, I can move the normalization closer to the Responses image-generation handling path. I mainly wanted to clarify that the reproduced issue is not limited to the Codex client itself. |
Summary
Normalize OpenAI Responses
image_generation_callitems that already contain a finalresultso they are returned withstatus: "completed"instead of preserving an upstream/intermediatestatus: "generating".Why
Some Responses image generation flows can produce a completed response and a valid base64 PNG in
image_generation_call.result, while the output item still hasstatus: "generating".That shape is confusing for strict Responses clients: the image payload is present, but the item still looks unfinished. In practice this can lead clients to treat the image result as blank or still pending.
The affected shapes are:
response.output[]response.output_item.done.itemresponse.completed.response.output[]The fix is intentionally conservative: only
image_generation_callitems with a non-emptyresultare marked completed. In-progress image calls without a result are left unchanged.Validation
node --check src/utils/common.js npm test -- --runInBand tests/responses-image-status-normalize.test.jsLocal result:
Also validated against a live OpenAI Responses-compatible route:
response.status=completed, image item has non-emptyresult, normalized tostatus=completedresponse.output_item.done.item.status=completedresponse.completed.output[0].status=completed