Repository navigation
fix(codex): materialize native tool-output images from raw response items - #154033
chelsealong wants to merge 2 commits into
Conversation
…tems Codex's ImageView tool (and other native tools) return screenshots as a raw function_call_output/custom_tool_call_output item whose output array carries a nested input_image data URL. The Codex media projector only recognized raw image_generation_call items, so this shape was dropped: the assistant text referenced the image but no attachment ever reached Control UI or the transcript. Extend CodexGeneratedMediaProjection.recordRaw to also scan tool-output items for input_image entries, validate them through the existing sanitizeInlineImageDataUrl guard, and materialize them through the same bounded media-save/delivery path already used for generated images. Fixes openclaw#153949
|
Thanks for picking this up. I found one correctness blocker against the issue acceptance criteria: this patch intentionally makes native screenshot/tool-output media produce The focused regression matrix should also cover both I have a narrow local candidate with those cases passing plus live Control UI before/after/reload verification in progress, and I’m happy to share the diff or test fixtures so we can converge on one PR rather than duplicate work. |
|
Codex review: needs real behavior proof before merge. What this changesThe Codex plugin saves images nested in raw tool-output events as reply attachments without counting them as image-generation side effects. Example: Codex reads /tmp/screenshot.png and returns its PNG bytes in a raw tool-output input_image entry.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 6 items remain Keep open: this PR addresses a current screenshot-delivery bug, but both previous correctness findings remain unresolved. Priority: P2 Before merge
Findings
Provenance
Tests
Agent review detailsHow this fits togetherThe Codex event projector translates app-server notifications into OpenClaw replies; its media owner converts image bytes into managed attachment references consumed by delivery and transcript persistence. flowchart TD
A[Codex tool output] --> B[Raw response notification]
B --> C[Codex media projector]
C --> D[Image validation]
D --> E[Gateway media store]
E --> F[Delivery receipt matching]
F --> G[Reply and transcript]
Technical reviewBest possible solution: Extend the existing Codex media owner with native-call correlation that preserves private host-tool results and original-path delivery aliases. Do we have a high-confidence way to reproduce the issue? The canonical report supplies a concrete raw event and missing-transcript result, and inspected current-main and release source reject that event shape; no target code was executed during this read-only review. Is this the best way to solve the issue? Reusing the existing bounded media owner is appropriate, but attachment eligibility must follow tool ownership and delivery identity rather than the presence of inline image bytes alone. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e7f054619274. Merge-risk optionsMaintainer options:
Provenance checked
TestingProof path: in-process harness. SecurityNeeds attention: The patch bypasses the existing private-inspection publication decision for echoed host-tool images. EvidenceSecurity concerns:
What I checked:
Likely related people:
PR surfaceSource +57, Tests +33. Total +90 across 2 files. Added test files: 0. View PR surface stats
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)
Reviewed October 27, 2026, 9:16 PM ET / October 28, 2026, 01:16 UTC (Revision 4). |
…ounting Projected native tool-output images (e.g. a screenshot from Codex's ImageView) were being tracked in the same identity set as real image-generation results, so hasGeneratedMedia() reported them as a billable/replay-unsafe side effect. Delivery media from a tool-output attachment carries no such side effect; only actual generated images do.
|
Fixed the correctness blocker: `hasGeneratedMedia()` was keyed off the same `itemIds` set used for projected tool-output attachments, so a native tool-output image (e.g. an ImageView screenshot) was flagged as a billable/replay-unsafe image-generation side effect. Split identity tracking so only actual image-generation results (native Left the broader test-matrix/identity-fallback suggestions for a follow-up so we don't duplicate the local candidate you mentioned — happy to look at your diff/fixtures if you want to share them. |
|
Re the remaining "real behavior proof" checklist item: I can't produce a live Codex round-trip or before/after Control UI screenshots from this sandbox — no OpenAI/Codex API credentials are provisioned, outbound network to the Codex API host is blocked, and this checkout is source-only (no |
|
Re-checked the sandbox specifically for this re-review round: |
|
Checked the `check-test-types-core-2` CI failure (log wasn't readable via the Checks UI, but `gh run view --log-failed` worked): ``` That file isn't touched by this PR (which only changes the two `extensions/codex` files listed above) and doesn't exist at all on this branch's HEAD — it's a No update to the "real behavior proof" checklist item: still no Codex API credentials or a built Control UI in this sandbox to produce a live before/after round trip, as noted in the two comments above. |
|
I rechecked the unchanged PR head and current main. Main still drops images nested in raw tool output. The October 6 review’s two findings remain unresolved on this branch: host-tool image echoes can bypass the private-inspection decision, and managed screenshot copies lack the original path needed for delivery matching. I made no code changes and cannot provide the requested live Codex screenshot and reload evidence from this environment. |
What Problem This Solves
Fixes #153949.
Codex's native
ImageViewtool (and other native tools that hand back animage) surfaces to OpenClaw as a raw
function_call_output/custom_tool_call_outputresponse item whoseoutputarray contains anested
{"type":"input_image","image_url":"data:image/png;base64,..."}entry.
CodexGeneratedMediaProjection.recordRaw(the Codex media owner)only recognized raw
image_generation_callitems and returned immediatelyfor anything else, so this event shape was silently dropped.
readCodexResponseOutputdeliberately omits non-text tool output from thetext transcript on the assumption that the media owner picks it up
(
extensions/codex/src/app-server/event-projector-tool-output.ts:129), sothe image bytes never reached the transcript or Control UI at all: the
assistant's reply referenced "the screenshot above" while no attachment
existed anywhere.
What Changed
CodexGeneratedMediaProjection.recordRawnow also inspectsfunction_call_output/custom_tool_call_outputraw items, scanningtheir
outputarray forinput_imageentries.image_urlis validated through the existingsanitizeInlineImageDataUrlguard (same validation already used forCodex history payload sanitization) and decoded via the existing
parseImageDataUrlhelper.recordImage/materializeImagepath already used forimage_generation_callresults, so they get the same size cap,concurrent-completion dedupe, and delivery/transcript wiring as
generated images, and are marked as a side effect
(
hadPotentialSideEffects).image_urlvalues are skipped (fail closed): noplaceholder, no partial write.
This is scoped to the raw-response-item media owner only; it does not
touch the
image_generation_callpath, billing/side-effectclassification for actual image generation, or the separate
dynamic-tool-image rendering path added in #120577 (which covers a
different event shape — dynamic tool results carried on typed thread
items, not this nested raw
input_imagepayload).Evidence
New regression test, reverted against the pre-fix source
(
git checkout HEAD~1 -- extensions/codex/src/app-server/event-projector-media.ts)to confirm it fails without the change:
Restored the fix and reran — passes:
Full relevant suites, all passing (89 tests):
Formatting/lint on the changed files:
node scripts/check-changed.mjs's repo-wide "line-cap growth ratchet"check fails in this checkout, but it fails identically (same file list,
same counts) on unmodified
upstream/mainwith these two files stashedout — it's flagging pre-existing large files unrelated to this change,
not anything this PR touches.
tsgo --noEmiton theextensions/codexproject reports 1618 errors inthis checkout, all
TS2307: Cannot find module 'openclaw/plugin-sdk/*'(missing generated plugin-sdk type declarations from a partial/source-only
dependency setup) plus pre-existing
any/unknownfindings in unrelatedfiles (e.g.
src/supervision-tools.ts,src/session-cli.ts). Confirmedthe exact same 1618-error count with this branch's two files stashed out
against unmodified
upstream/main— the type-resolution gap is anenvironment limitation of this sandbox, not something introduced here.
Was not able to run a live Codex app-server round-trip in this sandbox (no
Codex credentials/harness available here); the evidence above proves the
event-projection behavior through the same test harness and fixtures the
existing
image_generation_callregression tests in this file use.