Skip to content

fix(codex): show screenshots returned by native tools - #154125

Merged
obviyus merged 3 commits into
openclaw:mainfrom
sobechestnut-dev:fix/codex-tool-output-images
Oct 30, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
sobechestnut-dev:fix/codex-tool-output-images

Conversation

@sobechestnut-dev

@sobechestnut-dev sobechestnut-dev commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Native Codex tool screenshots arrive as input_image entries inside raw tool outputs, not only as image_generation_call results. OpenClaw was dropping those bytes before composing the assistant reply, leaving the Control UI without the screenshot, including after reload.

Summary

  • Preserve sobechestnut-dev's fix and promote validated inline images through the existing Gateway-managed media path.
  • Correlate function outputs with native imageView identities in either event order; keep unowned and host-dynamic outputs excluded so outbound policy cannot be bypassed.
  • Deduplicate repeated output events, enforce image-count and aggregate decoded-byte limits, and retain source-path aliases for delivery receipts.
  • Keep ordinary screenshots separate from generated-image side effects.

The native encoding was checked against Codex ce0323f2f2d3b25e82806cd555237da3db4e1897: codex-rs/protocol/src/models.rs lines 1166–1186 and 1212–1225 define function/custom output payloads; lines 2244–2258 define input_image; lines 928–934 define inline image_url; lines 2348–2352 allow structured content arrays. codex-rs/core/src/tools/handlers/view_image.rs lines 234–250 construct an inline image in a function output with the original call ID.

Evidence

Built Gateway and built Control UI, secretless Node 24.22.1 Docker, real Chromium, and a deterministic protocol-faithful Codex app-server fixture (not a claim of paid inference or execution of the real Codex binary). Real sessions, chat.send, agent.wait, and chat.history exercise the shipped turn and persistence path.

Before/after browser evidence is linked in the proof comment. The generated-image path is an unchanged control. Focused existing media suite: 11/11 passed; changed-file formatting passed.

Simplification

Removed the extra standalone regression suite and consolidated screenshot delivery coverage into the existing media suite, retaining source-alias, processed attachment, partial-delivery and generated-image assertions. Reused the canonical base64 estimator, removed forwarding/dead media paths, and replaced an unnecessary generated-ID set with a boolean. Against frozen main: production +241/-10 (251 gross), tests +29/-30 (net -1), no test/support allocation.

Observed before/after evidence: #154125 (comment)

Merge Danger

Two-way door: reverting restores the old projection behavior; no config or schema migration is introduced. Blast radius is native Codex inline tool-image projection and its media delivery receipts; generated-image and host-dynamic policy behavior must remain unchanged.

@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. extensions: codex size: M labels Sep 20, 2026
@sobechestnut-dev

Copy link
Copy Markdown
Contributor Author

Live Control UI verification

The workflow is identical in each capture: Codex calls view_image on the same local PNG and replies that the image is attached.

Before — attachment absent

Before: assistant refers to an attachment but no image is rendered

After — attachment rendered inline

After: the native tool-output image is rendered inline in the assistant reply

After full Control UI reload — attachment retained

After reload: the same inline attachment remains present in the transcript

The normal Gateway service was restored after this verification.

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 20, 2026
@sobechestnut-dev
sobechestnut-dev force-pushed the fix/codex-tool-output-images branch from 6b23833 to b4dde1e Compare September 20, 2026 22:32
@clawsweeper

clawsweeper Bot commented Sep 20, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The Codex plugin turns validated native tool-output images into managed reply attachments while preserving delivery deduplication and generated-image accounting.

Example: A native view_image call returns a 240×120 PNG inside function_call_output.

  • Before: The assistant refers to the screenshot, but chat and reloaded history contain no attachment.
  • After: Chat displays one screenshot, and the attachment remains after reload.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused repair with inspected shipped-Gateway proof, relevant negative controls, and preserved generated-image behavior.
Proof confidence 🦞 diamond lobster (5/6) ✨ media proof bonus Sufficient (screenshot): Candidate 05bf908 was exercised through built Gateway RPC sessions and real Chromium in secretless Docker with a protocol-faithful app-server fixture. Inspected before/after captures and the recorded history/reload results cover both event orders, duplicate events, generated-image controls, limits, and forbidden host-dynamic/unowned outputs; real Codex execution or paid inference is not claimed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: The assistant says a screenshot is attached while the user receives only text, including after reopening the conversation.
Reason: The repair restores requested screenshot delivery without adding configuration or a competing media pipeline, and collaborator involvement supports the direction.

Merge readiness

✅ Ready for maintainer review

This PR repairs a current screenshot-loss bug through the existing media owner; no actionable correctness or security finding remains.

Priority: P2
Reviewed head: 05bf908c5631376d334006ea590635d4774502f0

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The reported red-on-base unit replay timed out; the supplied shipped-Gateway comparison independently demonstrates the original failure and fixed behavior.
Agent review details

How this fits together

The Codex event projector receives native and raw app-server notifications, correlates tool identities, saves validated image bytes through Gateway media storage, and supplies attachment references to reply delivery and persisted history.

flowchart LR
  A[Codex app server] --> B[Turn event projector]
  B --> C[Native tool identity correlation]
  C --> D[Existing media projection owner]
  D --> E[Gateway media store]
  E --> F[Reply delivery and history]
  F --> G[Control UI]
Loading

Technical review

Best possible solution:

Land this focused media-owner repair after required checks pass, retaining host-dynamic exclusion and existing delivery receipts.

Do we have a high-confidence way to reproduce the issue?

Current-main source drops the reported structured tool images, and the supplied built-Gateway baseline comparison demonstrates the missing attachment; this review ran no target code.

Is this the best way to solve the issue?

The patch fixes the missing projection at its existing owner, reuses validation and storage contracts, and preserves generated-image and delivery semantics.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2c157ed06dff.

Provenance checked

  • Generated-image projection and replay accounting keeps the original intent (f870bea: Project raw generated images into managed media, deduplicate native/raw events, and retain generation side-effect evidence.)
  • Media-owner placement and notification ordering keeps the original intent (e20c029: Extract focused projection owners while preserving coordinator ordering around asynchronous media persistence.)
  • Host-owned attachment delivery keeps the original intent (bbad877: Deliver runtime-owned image output through host dispatch while maintaining ordinary source-reply suppression and outbound denial.)
  • Existing media regression suite keeps the original intent (test(core,plugins): remove low-value tests (batch d525) #183506: Consolidate repeated fixture setup while retaining distinct lifecycle, authority, and delivery coverage.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +231, Tests -1. Total +230 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 241 10 +231
Tests 1 29 30 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 270 40 +230

Review metrics

Metric Value Why it matters
Production versus test LOC Production +241/-10; tests +29/-30 Growth stays inside the existing media owner and supports correlation, bounds, and delivery identity; the regression reuses an existing suite without additional test scaffolding.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Missing native screenshot attachments break a bounded Codex chat workflow without disabling the overall runtime.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-20T22:40:05.145Z sha b4dde1e588f676e34d62829d113e1c8306f1458b :: needs changes before merge. :: [P2] [P2] Split tool-output coverage below the enforced test-file cap
  • reviewed 2026-09-20T23:19:23.175Z sha 9c36662ca40c3ce3e618fd000586a410d2cb73af :: needs changes before merge. :: none
  • reviewed 2026-09-21T00:10:33.626Z sha c3a7d75 :: needs changes before merge. :: none
  • reviewed 2026-09-21T14:18:47.773Z sha c3a7d75 :: needs changes before merge. :: none
  • reviewed 2026-10-06T23:08:21.399Z sha c3a7d75 :: needs changes before merge. :: none
  • reviewed 2026-10-06T23:16:17.092Z sha c3a7d75 :: blocked before merge. :: none

Reviewed October 30, 2026, 6:46 PM ET / 22:46 UTC (Revision 7).

@sobechestnut-dev
sobechestnut-dev force-pushed the fix/codex-tool-output-images branch from b4dde1e to 9c36662 Compare September 20, 2026 23:12
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 20, 2026
@sobechestnut-dev
sobechestnut-dev force-pushed the fix/codex-tool-output-images branch from 9c36662 to c3a7d75 Compare September 21, 2026 00:00
@sobechestnut-dev

Copy link
Copy Markdown
Contributor Author

Final local validation and CI shard diagnosis

The detached, resource-capped final validation completed after the desktop client disconnected:

  • pnpm test:extension codex equivalent extension batches: all 33 batches passed (26 extension-codex + 7 extension-database-workers)
  • wall time: 1h 2m 22s; CPU time: 1h 12m 46s
  • peak memory: 3.0 GiB; peak swap: 552.2 MiB
  • focused tool-output media suite: 15/15 passed in its single-worker batch; batch duration 45.61s (the 15 assertions themselves totaled about 0.3s)
  • the untouched event-projector.output-fidelity.native.test.ts file also passed 2/2 in the same full run; its 12-file single-worker batch duration was 249.50s

The sole GitHub failure is changed-extension shard 27, where those same two existing native-output-fidelity parameter cases reported a missing commandExecution. The failing file is not modified by this PR, and both cases pass locally on this exact head, including under the complete final suite. This is therefore consistent with a CI-only timing/flakiness issue rather than this patch’s media projection path. All other GitHub checks passed.

I attempted to rerun the failed workflow, but fork PR authors do not have repository-admin permission to rerun this upstream Actions run. A maintainer rerun of shard 27 is needed; no source change in this PR is indicated by the available evidence.

@sobechestnut-dev

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Built Gateway + real Chromium proof

Candidate 05bf908c5631376d334006ea590635d4774502f0; frozen main 00bfbf1f7ca54b0da62a10cc0d33323f3559dc02.

Secretless Node 24.22.1 Docker; separately built Gateway and Control UI on both refs; real Chromium; task-owned synthetic protocol-faithful app-server fixture. No real Codex binary execution, model inference, paid API key or operator login is claimed. The fixture emits the actual structured tool-result encoding inspected in upstream Codex.

Actual sessions were created through Gateway RPC, then chat.send, agent.wait, and chat.history; Chromium opened those persisted sessions and reloaded each.

case                              main history/browser/reload  candidate history/browser/reload
function screenshot, native first 0 / 0 / 0                    1 / 1 / 1
function screenshot, raw first    0 / 0 / 0                    1 / 1 / 1
image_generation control #1       1 / 1 / 1                    1 / 1 / 1
image_generation control #2       1 / 1 / 1                    1 / 1 / 1
custom output (duplicate events)  0 / 0 / 0                    1 / 1 / 1
unowned function output           0 / 0 / 0                    0 / 0 / 0
host dynamic-tool output          0 / 0 / 0                    0 / 0 / 0
malformed inline data             history 0                    history 0
oversized inline data             history 0                    history 0
nine custom output images         history 0                    history 8

Every rendered image decoded at 240×120 pixels. Repeated raw/native events did not duplicate attachments. Existing focused media suite passed 11/11, including ordinary screenshot side-effect=false and retained generated-image behavior; changed-file formatting passed. A separate baseline unit replay timed out during worker execution and is not counted as product evidence; its children were stopped. Initial catalog/route and startup-wait setup failures are not counted as defect reproduction.

Native source inspected at ~/Developer/codex HEAD ce0323f2f2d3b25e82806cd555237da3db4e1897:

  • codex-rs/protocol/src/models.rs:1166-1186,1212-1225: function/custom output payloads.
  • models.rs:2244-2258,928-934,2348-2352: input_image, inline image_url, structured content vector.
  • codex-rs/core/src/tools/handlers/view_image.rs:234-250: actual view_image constructs inline image output and preserves call_id.

Production +241/-10 (251 gross); existing test +29/-30 (net -1); no new test/support file. Contributor commits retained. No sibling PR code adopted.

Frozen main native-first screenshot missing

Candidate native-first screenshot rendered

Frozen main raw-first screenshot missing

Candidate raw-first screenshot rendered

@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 30, 2026
@obviyus
obviyus merged commit 96583dd into openclaw:main Oct 30, 2026
137 of 141 checks passed
@obviyus

obviyus commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator

Landed in 96583dd. Thanks @sobechestnut-dev. Images from native Codex tool outputs now show in chat.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 31, 2026
fix(codex): show images from native Codex tool outputs, such as screenshots

OpenClaw kept images from native Codex turns only when they came from `image_generation`. Images returned inside tool outputs never reached chat or history. Codex returns those as `input_image` content items in `function_call_output` and `custom_tool_call_output` (for example `view_image` in codex-rs/core/src/tools/handlers/view_image.rs:234-250, item shape in codex-rs/protocol/src/models.rs:2247-2259, at ce0323f2f2). They are now recorded and shown. Generated images are unchanged. Malformed, oversized, unowned and host-dynamic outputs stay excluded, with at most eight images per turn.

Evidence: built Gateway and Control UI in real Chromium with a protocol-faithful Codex app-server fixture (no real inference). Main showed no screenshot (twice). With this change exactly one was shown (twice), including after a reload and with either event order. Generated images worked on both refs, the excluded cases stayed excluded, and nine images were capped at eight. Details and screenshots: openclaw#154125 (comment).

Thanks @sobechestnut-dev.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 18, 2026
fix(codex): show images from native Codex tool outputs, such as screenshots

OpenClaw kept images from native Codex turns only when they came from `image_generation`. Images returned inside tool outputs never reached chat or history. Codex returns those as `input_image` content items in `function_call_output` and `custom_tool_call_output` (for example `view_image` in codex-rs/core/src/tools/handlers/view_image.rs:234-250, item shape in codex-rs/protocol/src/models.rs:2247-2259, at ce0323f2f2). They are now recorded and shown. Generated images are unchanged. Malformed, oversized, unowned and host-dynamic outputs stay excluded, with at most eight images per turn.

Evidence: built Gateway and Control UI in real Chromium with a protocol-faithful Codex app-server fixture (no real inference). Main showed no screenshot (twice). With this change exactly one was shown (twice), including after a reload and with either event order. Generated images worked on both refs, the excluded cases stayed excluded, and nine images were capped at eight. Details and screenshots: #154125 (comment).

Thanks @sobechestnut-dev.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 96583dd)

Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: codex P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: M status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants