fix(telegram): duplicate assistant messages in conversation context#100333
fix(telegram): duplicate assistant messages in conversation context#100333crabkun wants to merge 1 commit into
Conversation
The dedup key was `timestamp_ms:body` which fails when the same assistant reply appears in both the session transcript and the Telegram message cache with slightly different timestamps. Using body-only dedup prevents duplicate entries in the conversation context passed to the model.
|
Codex review: needs real behavior proof before merge. Reviewed July 5, 2026, 9:36 AM ET / 13:36 UTC. Summary PR surface: Source -3. Total -3 across 1 file. Reproducibility: yes. at source level. The PR makes the key only body text, and that key directly controls whether session transcript rows are removed before Telegram prompt context is sent to the model. Review metrics: 1 noteworthy metric.
Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review findings
Review detailsBest possible solution: Keep timestamp and sender/assistant identity as part of the dedupe safety boundary, then fix the remaining duplicate-context case with narrow normalized assistant-cache matching and live Telegram proof. Do we have a high-confidence way to reproduce the issue? Yes, at source level. The PR makes the key only body text, and that key directly controls whether session transcript rows are removed before Telegram prompt context is sent to the model. Is this the best way to solve the issue? No. Body-only matching is broader than the known duplicate-context problem; the safer fix is a narrow normalized assistant/cache match that preserves timestamp and identity guardrails. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against db96218c0562. Label changesLabel justifications:
Evidence reviewedPR surface: Source -3. Total -3 across 1 file. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
|
|
Superseded by the broader maintainer rewrite in #102469, landed as The canonical fix preserves a single durable projection path for chunked, rich-fallback, media, and streamed Telegram delivery while requiring a complete contiguous projection before suppressing transcript history. Focused Testbox coverage passed 779/779 tests, exact-head CI passed, and native Telegram Desktop Mantis proof passed: https://github.com/openclaw/openclaw/actions/runs/29133087432 Thanks for the contribution and the original reproduction. |
What Problem This Solves
Fixes an issue where users sending messages via Telegram would receive duplicate assistant replies in the conversation context passed to the model, doubling token usage and potentially confusing the model with repeated entries.
Each assistant reply appears twice: once from the session transcript (with a
session:-prefixed message ID) and once from the Telegram message cache (with the actual Telegram message ID). Both carry the same visible text but slightly different timestamps, causing the dedup key to differ and both copies to be retained.Why This Change Was Made
The dedup key in
resolvePromptContextTextDedupeKeywastimestamp_ms:body, which fails when the same assistant text appears in both sources with timestamps differing by milliseconds (session transcript gets the generation timestamp, Telegram cache gets the delivery timestamp).This change removes the timestamp component from the dedup key, using only the message body text. The overall dedup logic (removing session-transcript entries that already exist in the Telegram cache) remains unchanged; only the matching criterion is tightened.
User Impact
Evidence
#message_identry and a#session:<id>entry with identical text in the model context