fix(harness): make session JSONL offload idempotent#1774
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes a real and impactful bug: repeated offloadMessages() calls for the same session would re-append all historical messages, causing the session JSONL file to grow unboundedly. The fix is clean and minimal — it snapshots existing entry IDs after syncFromRemote(), then skips any incoming Msg whose stable ID is already present. The parent chain (lastId) is correctly initialized from the last existing entry. The regression test validates the core idempotency scenario well. One notable concern: when Msg.getId() is null or blank, dedup is silently bypassed, which could reintroduce the exact duplication bug under certain upstream conditions.
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
🤖 AI Review
This PR fixes a real and impactful bug: repeated offloadMessages() calls for the same session would re-append all historical messages, causing the session JSONL file to grow unboundedly. The fix is clean and minimal — it snapshots existing entry IDs after syncFromRemote(), then skips any incoming Msg whose stable ID is already present. The parent chain (lastId) is correctly initialized from the last existing entry. The regression test validates the core idempotency scenario well. One notable concern: when Msg.getId() is null or blank, dedup is silently bypassed, which could reintroduce the exact duplication bug under certain upstream conditions.
|
Addressed in the latest update on this branch. I also added a regression test for null/blank message IDs and re-ran |
AgentScopeJavaBot
left a comment
There was a problem hiding this comment.
All previously raised review comments have been addressed.
现象
在
HarnessAgent使用DistributedStore + RemoteFilesystemSpec时,同一个 session 多轮请求后,agents/<agentId>/sessions/<sessionId>.jsonl会持续变大,历史消息会被重复写入。复现步骤
HarnessAgentcontextFile/logFile/ DB 镜像内容预期行为
flush()后的 session JSONL 应保持幂等,不应随请求次数重复膨胀实际行为
影响
load()/syncFromRemote()成本越来越高验收标准