ACP session replay drops file attachment metadata and binary/text attachment handling #6676

Closed
opened 2026-02-16 18:04:55 -05:00 by yindo · 1 comment
Owner

Originally created by @liorshk on GitHub (Jan 18, 2026).

Originally assigned to: @rekram1-node on GitHub.

Description

Summary
When reloading an ACP session, file attachments are not replayed correctly, causing missing files, lost filenames, and incorrect rendering of text/binary content.

Problem
During session replay:

  • File parts in stored messages aren’t replayed to ACP clients.
  • Images lose their original filenames (always shown as “image”).
  • Binary files (PDFs, etc.) aren’t replayed.
  • Text files appear as inline text instead of attachments.
  • Synthetic text parts (LLM context) are incorrectly sent to ACP clients.

Expected
Attachments should be replayed with preserved filenames and correct ACP content block types, and synthetic text should be filtered out.

Actual
Attachments are missing or mis-typed, filenames are lost, and synthetic text is replayed.

Steps to Reproduce

  1. Start an ACP session and attach:
    • an image (e.g., photo.png),
    • a PDF (e.g., doc.pdf),
    • a text file (e.g., notes.txt).
  2. End the session.
  3. Reload the ACP session.
  4. Observe replayed content in the ACP client.

Proposed Solution
Update processMessage() in packages/opencode/src/acp/agent.ts to handle file parts during session replay:

  • file:// URLs → replay as resource_link
  • image/* → replay as image blocks, preserving original filename
  • text/* and application/json → replay as resource with decoded text
  • binary files → replay as resource with blob

Also update prompt() to:

  • Preserve filenames from resource_link.name and image.uri
  • Handle resource.blob by storing file parts with data URLs
  • Check resource.text truthiness (not just property existence)
  • Filter !part.synthetic when replaying text

Changes Outline

  • Add file part handling in processMessage() for replay
  • Filter synthetic text parts (!part.synthetic)
  • Preserve filename from resource_link.name in prompt conversion
  • Handle binary resource.blob in prompt()

Plugins

No response

OpenCode version

No response

Steps to reproduce

  1. Start an ACP session and attach:
  • an image (e.g., photo.png),
  • a PDF (e.g., doc.pdf),
  • a text file (e.g., notes.txt).
  1. End the session.
  2. Reload the ACP session.
  3. Observe replayed content in the ACP client.

Screenshot and/or share link

No response

Operating System

No response

Terminal

No response

Originally created by @liorshk on GitHub (Jan 18, 2026). Originally assigned to: @rekram1-node on GitHub. ### Description **Summary** When reloading an ACP session, file attachments are not replayed correctly, causing missing files, lost filenames, and incorrect rendering of text/binary content. **Problem** During session replay: - File parts in stored messages aren’t replayed to ACP clients. - Images lose their original filenames (always shown as “image”). - Binary files (PDFs, etc.) aren’t replayed. - Text files appear as inline text instead of attachments. - Synthetic text parts (LLM context) are incorrectly sent to ACP clients. **Expected** Attachments should be replayed with preserved filenames and correct ACP content block types, and synthetic text should be filtered out. **Actual** Attachments are missing or mis-typed, filenames are lost, and synthetic text is replayed. **Steps to Reproduce** 1. Start an ACP session and attach: - an image (e.g., `photo.png`), - a PDF (e.g., `doc.pdf`), - a text file (e.g., `notes.txt`). 2. End the session. 3. Reload the ACP session. 4. Observe replayed content in the ACP client. **Proposed Solution** Update `processMessage()` in `packages/opencode/src/acp/agent.ts` to handle `file` parts during session replay: - `file://` URLs → replay as `resource_link` - `image/*` → replay as `image` blocks, preserving original filename - `text/*` and `application/json` → replay as `resource` with decoded `text` - binary files → replay as `resource` with `blob` Also update `prompt()` to: - Preserve filenames from `resource_link.name` and `image.uri` - Handle `resource.blob` by storing file parts with data URLs - Check `resource.text` truthiness (not just property existence) - Filter `!part.synthetic` when replaying text **Changes Outline** - Add file part handling in `processMessage()` for replay - Filter synthetic text parts (`!part.synthetic`) - Preserve filename from `resource_link.name` in prompt conversion - Handle binary `resource.blob` in `prompt()` ### Plugins _No response_ ### OpenCode version _No response_ ### Steps to reproduce 1. Start an ACP session and attach: - an image (e.g., photo.png), - a PDF (e.g., doc.pdf), - a text file (e.g., notes.txt). 2. End the session. 3. Reload the ACP session. 4. Observe replayed content in the ACP client. ### Screenshot and/or share link _No response_ ### Operating System _No response_ ### Terminal _No response_
yindo added the bug label 2026-02-16 18:04:55 -05:00
yindo closed this issue 2026-02-16 18:04:55 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 18, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #4870: ACP session/load does not replay the conversation
  • #7804: ACP loadSessionMode doesn't restore persisted model/agent from session messages
  • #8766: Migrate synthetic message detection to metadata-based approach
  • #8807: Unhandled ENOENT error when submitting a message with a deleted file attachment
  • #8806: File completion dialog stays open when selecting a file with text behind
  • #9210: Reading .fbs files fails with "Unsupported image mime type"

These issues collectively describe similar ACP session replay and file attachment handling problems. Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 18, 2026): This issue might be a duplicate of existing issues. Please check: - #4870: ACP `session/load` does not replay the conversation - #7804: ACP loadSessionMode doesn't restore persisted model/agent from session messages - #8766: Migrate synthetic message detection to metadata-based approach - #8807: Unhandled ENOENT error when submitting a message with a deleted file attachment - #8806: File completion dialog stays open when selecting a file with text behind - #9210: Reading .fbs files fails with "Unsupported image mime type" These issues collectively describe similar ACP session replay and file attachment handling problems. Feel free to ignore if none of these address your specific case.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#6676