Skip to content

fix: stop conv replay pollution in lossless-claw#263

Merged
jalehman merged 3 commits intomainfrom
fix/conv642-heartbeat-lcm-live
Apr 4, 2026
Merged

fix: stop conv replay pollution in lossless-claw#263
jalehman merged 3 commits intomainfrom
fix/conv642-heartbeat-lcm-live

Conversation

@jalehman
Copy link
Copy Markdown
Contributor

@jalehman jalehman commented Apr 4, 2026

What

Fix two conversation-integrity bugs in lossless-claw that surfaced in the agent:main:main conv 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 during afterTurn() could fail when runtime sessionId changed but stable sessionKey continuity 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

  • Prune heartbeat-shaped ACK turns before compaction
  • Stop persisting compaction telemetry as messages
  • Dedup replay by sessionKey continuity first
  • Add focused conv642 regression coverage

Testing

  • npm test -- test/engine.test.ts
  • Verified live gateway restart and conv 642 stabilized

jalehman added 3 commits April 3, 2026 21:20
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.
@jalehman jalehman merged commit 65f14bc into main Apr 4, 2026
2 checks passed
@jalehman jalehman deleted the fix/conv642-heartbeat-lcm-live branch April 4, 2026 06:50
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