Skip to content
Source
Sign inSign up
pingdotgg/t3code

[Bug]: Re-embedding an overwritten local image shows the old cached version #15676

Closedbtsouth(GitHub profile, opens in a new tab) opened this issue 6 comments

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

No open issue covers this. #13942 and #14009 addressed the same problem and were closed under the prior-approval rule, so this issue is for maintainers to decide the intended behavior.

Area

apps/server, apps/web

Actual behavior

An agent regenerated an image by overwriting the same PNG it had embedded earlier in the thread, then embedded that path again in its reply. The new message showed the old image. Opening the same file from the files panel showed the correct, updated image, so the two views disagreed side by side.

The file on disk was correct, and the agent had read the new file back before replying.

Steps to reproduce

  1. Have an agent write an image to a path, for example /tmp/chart.png, and embed it in a reply with ![chart](/tmp/chart.png).
  2. Within an hour, have it overwrite that file with different content and embed the same path in a new reply.
  3. The new reply shows the previous image.
  4. Open the file from the files panel. It shows the current image.

Expected behavior

A message that embeds a local image shows the file as it was when the message was written, or at least never shows an older version than the one on disk.

Cause

Two caches key only on the path:

  • The client reuses the signed asset URL per resource path for up to an hour (useAssetUrlState, ASSET_URL_IDLE_TTL_MS in packages/client-runtime/src/state/assets.ts).
  • The server serves images with Cache-Control: private, max-age=3600 (assetResponseHeaders in apps/server/src/http.ts). The token does not include the file's mtime or size.

Audio and video already get no-store because "host media can change in place", but images do not.

Confirmed on main at 4ee6bfd5.

Open question

The closed PRs show the possible directions:

  1. Treat local images as live references and revalidate them (for example no-cache with an mtime/size ETag). Small change, but older messages would also switch to the newest file.
  2. Snapshot referenced images per message (#14009). Preserves history, but adds storage and retention.
  3. Prompt-only guidance to write revisions to new file names (#13942).

Which behavior is intended?

Impact

Minor bug. Misleading when an agent iterates on an image or screenshot, because the chat shows a result that does not match the file.

Version or commit

0.0.46-nightly.20261004.2648. Cause confirmed on main at 4ee6bfd5.

Environment

Linux, T3 desktop app, Claude provider.

Workaround

Reload the window, open the file from the files panel, or have the agent write each revision to a new file name.

  1. Note

    Grok responding on behalf of Julius.

    Triage

    Thanks for the write-up, @btsouth, and for linking the two closed PRs, which give useful context.

    What I found

    Confirmed on main at 4ee6bfd50e.

    • Chat reuses a cached URL. Chat embeds a local image as a media-file resource and renders whatever useAssetUrlState already has (ChatMarkdownAssetImage in apps/web/src/components/ChatMarkdown.tsx). That cache is keyed by the resource, not by the file's contents.
      • While the thread stays open, the signed URL refreshes every 30 minutes.
      • A new subscriber doesn't refetch during the 5-minute stale window.
      • An unused entry lives for an hour.
      • The timings are set in packages/client-runtime/src/state/assets.ts, and mobile uses the same hook.
    • The token doesn't track content. The signed claims are path, device, and inode, plus a one-hour expiry (finalizeAbsoluteMediaFileAsset in apps/server/src/assets/AssetAccess.ts). Overwriting a file in place keeps its inode, and the token carries no mtime or size. The old pixels come from reusing the URL.
    • Images are cacheable, unlike other media. Images get Cache-Control: private, max-age=3600 (assetResponseHeaders in apps/server/src/http.ts), while audio and video are rewritten to private, no-store in assetFileResponse.
    • Why the files panel shows the right image. WorkspaceImagePreview signs a workspace-file URL with a workspace-revision taken from the latest file change, command, or checkpoint (FilePreviewPanel.tsx, workspaceMutationId in ChatView.tsx). That skips both caches, and reloading has the same effect, which matches your workaround.
    • Files outside the project. Absolute paths like /tmp/chart.png still go stale in chat, but the files panel only resolves files inside the workspace root.

    Likely fix area

    The options line up with the ones you listed. Picking one is a decision about what an image path in a message should mean over time:

    • Revalidate like audio and video, using no-store, or no-cache with an mtime/size validator, and don't reuse a cached URL for a new message. This is a small change, but older messages would also show the newest file once their cached copy expires.
    • Snapshot the image when the message is written, as in #14009. This keeps history but adds storage and retention.
    • Have agents use a new file name for each revision, as in #13942. This avoids the cache but doesn't fix a reused path.

    A maintainer will decide on the fix direction.

  2. juliusmarminge added labelsbug

  3. juliusmarminge added labelsvia-triage

  4. Reproduced on Linux in the web dev app at b5a226e49c, with Claude Sonnet 5.5. The agent created a red 100×100 PNG, embedded its absolute path, then overwrote it in place with green pixels and embedded the same path in a second reply. The new reply still displayed red: rendered pixel RGB 255,0,0; PNG on disk RGB 0,255,0. Reloading the page displayed green.

    Reproduction capture.

    Checked all 947 open issues. #13138 covers expanded image-read tool outputs; this report covers Markdown images in replies.

  5. Fix proposed in #23212. The real web app shows stale bytes on b5a226e49c; paired recordings show the later reply fetching the overwritten image after the fix, without reload. Evidence and coverage limits.

    At e76c41919d, 28 focused tests and web/mobile/client-runtime typechecks pass. Native iOS builds failed resolving GhosttyKit; Electron and Android are unverified. Streaming/reconnect and remaining fixture gaps are listed in the PR for maintainer review.

  6. Confirmed on 0.1.2, from a different setup and a long-running thread.

    Environment

    • T3 Code 0.1.2 server on Linux x64 (WSL2), desktop client connected remotely
    • Agent: OpenCode, in a thread kept open across the whole repro

    Repro (matches your steps exactly)

    • The agent embedded the same workspace-relative image path in five replies over roughly 13 hours (2026-10-27T15:17Z through 2026-10-28T04:01Z).
    • The file was rewritten in place at 04:00:58Z. The 04:01Z reply still rendered the earlier image, so the message on screen disagreed with the file on disk.
    • Writing the next capture to a new, timestamped filename displayed the new image correctly, which matches the "use a new filename" behavior in the report.

    Cache behavior still present in 0.1.3

    I checked the v0.1.3 tree: assetResponseHeaders in apps/server/src/http.ts still sends Cache-Control: private, max-age=3600 for images, and packages/client-runtime/src/state/assets.ts still keys the signed URL on the resource path only, with a 5-minute stale window, 30-minute refresh, and 1-hour idle TTL. Updating past 0.1.2 does not avoid this.

    Workaround

    Use a unique filename per revision, or reload the window. For files inside the workspace, opening the file from the Files panel also shows the current bytes.

    Produced by DeepSeek V4.1 Flash via OpenCode in T3 Code's t3 triage.

  7. Reproduced on T3 Code 0.1.5 (Beta), macOS, 1 Nov 2026. The file was a GIF. A new path with the same bytes, embedded in the same later message, showed the new animation.

    1. Write repro-cache-a.gif: 28330 bytes, sha256 348a58db9aff1ee86a24dcae65cdba4c73bf82749ff1309c5d970be91ee7339a, 4 frames at 3000 ms, burned-in label A-SLOW. Write repro-cache-b.gif: 23220 bytes, sha256 549d97f8596108b73f076465e59635446e2c35d96264aab5d94dcc60be5c07ee, 4 frames at 100 ms, label B-FAST.
    2. Embed both absolute paths in one message. A-SLOW held at 3000 ms. B-FAST held at 100 ms. Frame delays work on a path that has not been embedded before.
    3. Overwrite repro-cache-a.gif in place and copy those bytes to repro-cache-a-copy.gif. Both files: 16341 bytes, sha256 87bbe5618fb8afc631fcadcece0ede6daead6e09182f6cdb597ec81a554674ab, 2 frames at 500 ms, label A-OVERWRITE.
    4. In a later message, embed both paths.

    Expected: both play A-OVERWRITE, 2 frames at 500 ms.

    Actual: repro-cache-a.gif still played A-SLOW at 3000 ms. I watched that image. It rendered as A-SLOW at 3000 ms. repro-cache-a-copy.gif played A-OVERWRITE at 500 ms.

    The labels and the hold times are pixels in the GIF.

    #23213 is still open, and its notes say the desktop client was not verified. This run was the macOS beta. Workaround: embed each revision at a new path.

  8. Thanks for the detailed report! #29741, merged as e0f69e9, refreshes chat images when the agent rewrites the file, treating them as live references.

  9. juliusmarminge closed this

Sign in to join this conversation.