[Feature]: Offload base64 image data from AgentStateStore to reduce history retrieval overhead
Problem
When AgentStateStore stores an ImageBlock that contains a base64-encoded image (transmitted in that format), it writes the full base64 string into stateData. This string is often very large, which significantly increases the time spent on retrieving or parsing historical messages.
Solution
Offload the base64-encoded image string to a new field or a separate table, and replace it with a placeholder in the original ImageBlock. Then, in the method that assembles historical messages for the model, add a step to restore the base64 data from the offloaded storage. This way, for routine history-reading operations, developers can choose not to query the base64 data.
问题
AgentStateStore 存储 base64 格式传输的图片消息 ImageBlock 时,会将图片的 base64 编码字符串存到 stateData 中,而这个字符串往往很大,这导致获取/解析历史消息的耗时显著变长。
方案
将图片的 base64 编码字符串卸载到一个新字段或者新表中,原 ImageBlock 中使用占位符替代,在模型组装历史消息的方法中增加还原 base64 编码的操作。这样一来,常规的历史消息读取处理时,开发者可以选择不查询 base64 编码信息。
Issue Evaluation
Category: enhancement | Area: area/core/memory | Status: Evaluated
Feasibility: Feasible but broad. Verified on current main: Base64Source.data (Base64Source.java:44) stores the full base64 string inline, and the entire serialization chain — Msg → AgentState → AgentStateStore.save() → JSON — writes it verbatim. No offloading or placeholder mechanism exists anywhere in the persistence path. SessionTranscriptWriter (line 344) already demonstrates the pattern of recording only block type names rather than image data.
Scope: Core changes needed in Base64Source / ImageBlock (placeholder + reference key), the state save/load path in ReActAgent and StateBackedMemory (offload before save, restore before model assembly), and potentially a new offload storage abstraction. All AgentStateStore implementations (JDBC, MongoDB, Redis, PostgreSQL, etc.) would benefit transparently if the offload happens before the store call.
Compatibility: The ImageBlock / Base64Source wire format is part of the public message model. Any placeholder scheme must round-trip correctly with existing persisted state that contains inline base64 data (backwards-compatible deserialization).
Automated evaluation by github-manager-bot