Reused workdir image filenames overwrite earlier chat bubbles after UI reload
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
- 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. - Generate again, overwriting the same filename with different bytes.
- Scroll older bubbles: some may still show earlier pixels until the page is rebuilt.
- Reload the Agent Zero UI.
- 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.
Source: agent0ai/agent-zero