Skip to content

fix(history): strip binary image blobs from chat.json serialization#1226

Open
vanja-emichi wants to merge 1 commit intoagent0ai:developmentfrom
vanja-emichi:fix/history-strip-image-blobs
Open

fix(history): strip binary image blobs from chat.json serialization#1226
vanja-emichi wants to merge 1 commit intoagent0ai:developmentfrom
vanja-emichi:fix/history-strip-image-blobs

Conversation

@vanja-emichi
Copy link
Copy Markdown
Contributor

RawMessage content (base64-encoded images) was being written verbatim to chat.json during disk serialization. This caused two problems:

  1. chat.json bloated to MBs after any image-containing conversation
  2. Reloaded chats would re-send the full image blob to the LLM on every subsequent call, inflating token usage and context size.

Fix: detect RawMessage content in Message.to_dict() and replace it with the preview text (if present) or a placeholder string before persisting. Binary blobs are ephemeral — they are only valid for the current LLM session and should never be stored on disk.

RawMessage content (base64-encoded images) was being written verbatim
to chat.json during disk serialization. This caused two problems:
1. chat.json bloated to MBs after any image-containing conversation
2. Reloaded chats would re-send the full image blob to the LLM on
   every subsequent call, inflating token usage and context size.

Fix: detect RawMessage content in Message.to_dict() and replace it
with the preview text (if present) or a placeholder string before
persisting. Binary blobs are ephemeral — they are only valid for the
current LLM session and should never be stored on disk.

Co-authored-by: BMad Master <bmad@agent-zero>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant