[Bug]: Codex `view_image` preview shows "Image unavailable" after the agent deletes the temporary image file #41480
Summary#
When a Codex agent creates a temporary screenshot (e.g. via screencapture), inspects it with view_image, and then deletes the temporary file before finishing the turn, the chat timeline renders an empty placeholder: "Image unavailable · ".
Steps to reproduce#
- Start a Codex thread in T3 Code (tested on
0.1.12-nightly.20261123.5124). - In the same turn, have the agent run a command that writes a temporary image (e.g.
screencapture -x screen.pnginside~/.t3/scratch/...), callview_imageon it, and then clean up (rm screen.png). - View the thread in T3 Code.
Expected behavior#
The inspected image remains viewable in the thread history, even after the temporary file on disk is removed (just like user-uploaded attachments or MCP app snapshots stored in ~/.t3/userdata/attachments/).
Actual behavior#
The dynamic_tool (view_image) turn item stores only the live path (viewedImagePath), and the UI resolves it directly from disk. Once the temporary file is deleted, the preview permanently degrades to "Image unavailable · screen.png".
Proposed fix#
When ingesting a completed view_image / imageView item whose viewedImagePath exists on disk, snapshot the image into ~/.t3/userdata/attachments/ (deduplicated per thread by hash, cleaned up on thread deletion) and reference that attachment ID as the primary or fallback source for the preview.
Environment#
- T3 Code:
0.1.12-nightly.20261123.5124(macOS desktop + remote linked environment) - Provider: Codex (
view_image/imageView)
tanstack-source added labelsbug
Note
🤖 Claude Opus 5.5 responding on behalf of JinJieBeWater
This also happens with Claude Code's
Read, onmainat 8cf94f2542. Snapshotting the image on the server, as proposed above, looks like the right fix, because the agent can't avoid this on its own side.Reproduction (one turn, Claude provider):
- The agent writes
/tmp/t3table/current.pngwith a headless Chromium script. - It calls
Readon the PNG to check the result. - At the end of the turn it runs
rm -rf /tmp/t3tableto clean up its scratch files. - The viewed-images strip under that tool group now shows "Image unavailable · current.png".
Two observations:
- Instructions can't fix this. The agent opened the image for its own check; it wasn't trying to show it to the user. It can't see which of its files end up in the user's timeline, so a rule like "keep images you showed the user" is one it can't follow. A rule like "keep every image you
Read" would conflict with the common instruction to clean up scratch files. The fix has to live in T3 Code. - Claude already stores the bytes. The persisted
Readitem's output contains the full base64 PNG (more than 60 KB in this case), but the strip still resolvesviewedImagePathfrom disk. Other providers only record the path (Antigravity, per the comment above), so a server-side snapshot at ingest covers every adapter and keeps image bytes off the wire, like theoutputOmittedhandling from #30473.
- The agent writes
EliBlauBalto(GitHub profile, opens in a new tab) linked this to #47940
Sign in to join this conversation.
Confirming this also reproduces outside Codex, on Antigravity (ACP) (
0.1.12-nightly.20261122.5111, Linux) whenever the agent saves temporary screenshots (e.g./tmp/step-1.jpg), inspects them withRead, and removes them withrm -fafterwards.Two additional details from server traces (
server.trace.ndjson) and client bundle inspection that may help when fixing this:viewedImagePathwith no inline bytes): On Antigravity ACP,Readturn items persistviewedImagePathwith no inlineoutputimage bytes, sodata-image-galleryresolves the file live viaws.rpc.assets.createUrl(media-file). After the file is deleted, every subsequent lookup fails withAssetWorkspaceAssetNotFoundError: Media file was not found.(142/142 asset URL failures in our server trace logs). Even on providers that include base64 bytes in tool outputs, the collapsedviewed-imagesgallery still resolves viamedia-filefrom disk.workspaceMutationIdAtom(which advances whenever anycommand_execution,file_change,dynamic_tool, orsubagentitem completes) as the refresh revision formedia-fileresources, deleting a file after its thumbnail has already loaded in an open browser tab causes the next completed tool call to re-runassets.createUrl, receiveAssetWorkspaceAssetNotFoundError, and replace the loaded image withImage unavailableright in front of the user.Snapshotting
viewedImagePathon completedRead/view_imageitems (as proposed above) fixes both persistence and reboots (/tmpontmpfs). As a complementary client guard, retaining an already-loaded image instead of overwriting it withImage unavailablewhen a backgroundworkspaceMutationIdrefresh returnsAssetWorkspaceAssetNotFoundErrorwould also stop live previews from disappearing mid-turn.