agent-zero icon indicating copy to clipboard operation
agent-zero copied to clipboard

Reused workdir image filenames overwrite earlier chat bubbles after UI reload

Open bdunn77 opened this issue 3 months ago • 1 comments

Summary

Chat bubbles that embed generated images via live workdir paths (for example img:///a0/usr/workdir/logo.png or /api/image_get?path=...) do not keep a historical copy of the file. If Agent Zero later reuses the same filename, older bubbles start showing the newest image. Reloading the WebUI makes this ubiquitous because replay re-fetches every URL from disk.

A second overlapping bug: /api/image_get served a generic fallback icon with Cache-Control: public, max-age=3600 when the file was missing. The browser could cache that icon under the PNG URL, so some bubbles failed to load even before a reload, then mixed icons/latest-bytes after reload.

Steps to reproduce

  1. In one chat, generate an image and have the response markdown point at a stable workdir path such as usr/workdir/out/board_submit.png.
  2. Generate again, overwriting the same filename with different bytes.
  3. Scroll older bubbles: some may still show earlier pixels until the page is rebuilt.
  4. Reload the Agent Zero UI.
  5. Every bubble that used that filename now shows the latest file.

Expected

Each finished chat bubble should keep the image that was shown at the time it was written. Reloading the UI should not rewrite history when a later generation reuses a filename. Missing files should not cache a fallback icon as if it were the requested PNG.

Actual

Chat markdown stores live paths, not unique snapshots. /api/image_get serves whatever currently exists at that path, and missing-file fallbacks were cached for an hour. Browser screenshots and vision-load artifacts already use unique chat-scoped names. Response-embedded workdir images did not.

Notes

  • Forward-looking only: already overwritten files cannot be restored from chat.json.
  • I could not find an existing issue or PR for this. Related but different: image_get path security, vision-load unique artifacts, screenshot snapshots, and stripping binary blobs from history.

bdunn77 avatar Aug 30 '26 05:08 bdunn77

Adding a distinct trigger for the same root cause: the message queue (not workdir filename reuse).

Reproduction

  1. While the agent is busy (or a queue already exists), attach a pasted/clipboard image and send. The send is routed to messageQueueStore.addToQueue() (webui/index.js:131) instead of /message_async.
  2. The queue renders a pending item immediately, before the async /upload finishes. Its thumbnail is <img src="/api/image_get?path=/a0/usr/uploads/clipboard-<guid>.png"> (message-queue.html:41, URL built in message-queue-store.js:240).
  3. That file does not exist yet, so /api/image_get returns the fallback icon with Cache-Control: public, max-age=3600, and the browser caches the green image.svg under the PNG URL.
  4. When the queued message is later sent, helpers/message_queue.py logs kvps.attachments = ["clipboard-<guid>.png"] via log_user_message(), and drawMessageUser (webui/js/messages.js:2121) renders the same /api/image_get?path=... URL. The file now exists on disk, but the browser serves the cached fallback icon.

Observed

  • The chat bubble shows the green document fallback icon instead of the image.
  • The model still receives the real image correctly (the backend logs the correct basename and the file does exist in /a0/usr/uploads), which matches the "AI sees it, the user does not" symptom.
  • Confirmed on current main: api/image_get.py still sets Cache-Control: public, max-age=3600 on every image response, including the missing-file fallback.

Relation to #1866

PR #1866's no-store for missing-file fallbacks fixes this symptom. A secondary robustness improvement would be for the queue preview to keep using the local blob URL for pending items until the upload resolves, so it never requests the not-yet-existing server path.

bdunn77 avatar Sep 21 '26 16:09 bdunn77