fix(telegram): normalize directive tags in prompt context dedupe key#100571
fix(telegram): normalize directive tags in prompt context dedupe key#100571tzy-17 wants to merge 1 commit into
Conversation
|
Thanks for the context here. I did a careful shell check against current Close: current main already fixes the central Telegram directive-tag duplicate prompt-context problem through the merged timestamp-preserving implementation in #100573, while this branch remains a broader body-only dedupe path that should not be a landing candidate. Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. So I’m closing this as already implemented rather than keeping a duplicate issue open. Review detailsBest possible solution: Keep the merged timestamp-preserving directive-strip implementation from #100573 on current main and close this overlapping body-only branch. Do we have a high-confidence way to reproduce the issue? Yes. The linked issue gives concrete duplicate Telegram prompt-context rows, and current main now has a handler regression that exercises the directive-tag transcript row plus cache row path. Is this the best way to solve the issue? No. This branch is no longer the best fix because current main already landed a narrower implementation that normalizes directive tags while preserving timestamp alignment. Security review: Security review cleared: No concrete security or supply-chain concern found; the diff is limited to Telegram runtime code and adds no dependencies, workflows, permissions, credentials, downloads, or lifecycle hooks. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 2a741bebb54f; fix evidence: commit e0d23cfc5a26, main fix timestamp 2026-07-06T08:11:08Z. |
3834a45 to
249d882
Compare
resolvePromptContextTextDedupeKey used exact timestamp_ms:body matching, which failed when the same assistant reply appeared with [[reply_to_current]] tags in the session transcript copy but without them in the Telegram cache copy. This produced duplicate assistant entries in prompt context. Fix: strip inline directive tags and #session:<id> synthetic ids from the body before computing the dedupe key, so transcript and cache copies of the same visible reply are recognized as duplicates. Fixes openclaw#99117
249d882 to
9916a11
Compare
|
ClawSweeper applied the proposed close for this PR.
|
What Problem This Solves
Fixes #99117: In Telegram direct chats, the same assistant reply appeared twice in prompt context — once from the session transcript (with
[[reply_to_current]]directive tags and#session:<id>synthetic IDs) and once from the Telegram message cache (without tags). The dedupe key used exacttimestamp_ms:body.trim()matching which failed because the two copies differed in both body and timestamp.Why This Change Was Made
resolvePromptContextTextDedupeKeycompared exacttimestamp_ms:body, but:[[reply_to_current]],[[reply_to:<id>]],[[audio_as_voice]]) prepended; cache copies don't#session:<id>synthetic IDs only appear in transcript copiesThe fix normalizes the body by stripping directive tags and
#session:<id>prefixes before computing the dedupe key, so transcript and cache copies of the same visible reply are recognized as duplicates.User Impact
Evidence
resolvePromptContextTextDedupeKeyatbot-handlers.runtime.ts:187as the single dedupe pointpnpm test extensions/telegram/src/bot-handlers.runtime.test.ts— 4 tests passpnpm test extensions/telegram/src/bot-message-context.prompt-context.test.ts— 4 tests passpnpm test extensions/telegram/src/session-transcript-context.test.ts— 6 tests passoxlintpasses on changed file🤖 Generated with Claude Code