fix: stop conv replay pollution in lossless-claw#263
Merged
Conversation
Resolve the conv642 replay-regression in the afterTurn dedup guard by looking up the stored conversation through the same stable session identity used elsewhere in the engine. The dedup path now prefers sessionKey continuity and only falls back to sessionId through the existing store helper, which prevents restart replays from being treated as fresh history when OpenClaw rotates the runtime sessionId for the same top-level session. Add a focused regression covering restart replay under agent:main:main with a changed runtime sessionId. Regeneration-Prompt: |\n Fix the conv642 / 0.6.0 replay-regression in lossless-claw without broad refactoring. The likely bug is that afterTurn replay dedup looks up prior history by sessionId too loosely, while the rest of the engine already treats stable sessionKey continuity as the canonical identity for a live conversation. Make the smallest code change that brings replay dedup into line with the existing getConversationForSession behavior, preserving current fallback behavior when no sessionKey exists. Add focused regression coverage for the real failure mode: a restart or runtime recycle changes the sessionId but keeps the same stable sessionKey, and the replayed historical prefix must still be deduplicated instead of re-ingested. Keep the scope limited to the conv642 replay issue.
Refresh the lcm integration tests to match the intended compaction-telemetry cleanup. The compaction engine still reports meaningful result metadata and persists summaries, but it no longer writes synthetic compaction message parts into canonical transcript state. Replace the stale compaction-part assertions with checks that no compaction parts are persisted while leaf and condensed compaction still reduce tokens and create the expected summaries/context transitions. Regeneration-Prompt: |\n CI started failing in test/lcm-integration.test.ts after the compaction-telemetry cleanup because two integration tests still expected synthetic compaction parts to be persisted into canonical transcript output. Update those tests only. Keep the new assertions meaningful: verify that canonical transcript state stays free of compaction parts, while compaction still returns useful result metadata, reduces token counts, and creates leaf/condensed summaries and summary context items as appropriate. Rerun the relevant integration file, then a slightly broader pass including engine tests to confirm the branch remains green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Fix two conversation-integrity bugs in lossless-claw that surfaced in the
agent:main:mainconv 642 incident: heartbeat-shaped ACK/tool turns could leak into LCM history and synthetic compaction telemetry was being persisted as canonical conversation messages, and replay dedup duringafterTurn()could fail when runtimesessionIdchanged but stablesessionKeycontinuity remained the same.Why
On the live system, these behaviors combined into a bad failure mode: historical content could be re-ingested into the main conversation, heartbeat/tool turns accumulated instead of being pruned, and compaction spam polluted the transcript. That inflated conv 642 dramatically and correlated with long typing / silence and pathological compaction churn.
Changes
Testing