fix(telegram): dedupe visible assistant prompt context#100573
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 6, 2026, 3:40 AM ET / 07:40 UTC. Summary PR surface: Source +11, Tests +131. Total +142 across 4 files. Reproducibility: yes. source-reproducible. Current main dedupes Telegram session/cache prompt rows by exact timestamp plus raw body, and the linked issue provides concrete installed-release duplicate context rows. Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. 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 detailsBest possible solution: Land one timestamp-preserving directive-strip dedupe fix with handler/dispatch regression coverage and redacted live or QA hidden-context proof, then close the canonical issue and supersede overlapping PRs. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible. Current main dedupes Telegram session/cache prompt rows by exact timestamp plus raw body, and the linked issue provides concrete installed-release duplicate context rows. Is this the best way to solve the issue? Yes for the code shape, but not yet for merge readiness. The PR preserves the timestamp guardrail and reuses the delivery-visible directive stripper instead of switching to a broad body-only dedupe key, but it still needs real hidden-context proof. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 9302c80ca6b8. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +11, Tests +131. Total +142 across 4 files. 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
|
|
@openclaw-mantis telegram desktop proof: verify that a Telegram DM follow-up after an assistant reply using [[reply_to_current]] includes only one prior visible assistant context row. |
Mantis Telegram Desktop ProofSummary: Mantis did not generate before/after GIFs because the PR changes hidden Telegram conversation context rather than Telegram-visible chat behavior.
|
|
@openclaw-mantis telegram desktop proof: verify that a Telegram DM follow-up after an assistant reply using [[reply_to_current]] includes only one prior visible assistant context row. |
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
@clawsweeper automerge |
|
🦞✅ Approver: What merged:
Automerge notes:
The automerge loop is complete. Automerge progress:
|
|
🦞✅ Source: Why human review is needed: What the maintainer can do as a next step: I added |
|
@clawsweeper re-review |
|
@clawsweeper approve |
Summary: - Merged fix(telegram): dedupe visible assistant prompt context after ClawSweeper review. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(telegram): align directive reply prompt timestamps Validation: - ClawSweeper review passed for head 5c4cc72. - Required merge gates passed before the squash merge. Prepared head SHA: 5c4cc72 Review: openclaw#100573 (comment) Co-authored-by: momothemage <[email protected]> Approved-by: momothemage
…p [AI] PR openclaw#100573 added stripInlineDirectiveTagsForDelivery to both resolvePromptContextTextDedupeKey and normalizePromptContextTimestampText, but directive-tag stripping alone does not normalise Markdown emphasis characters (* _ ` ~). When the session transcript stores the assistant reply with Markdown formatting (e.g. **bold**) but the Telegram message cache stores the rendered text without it (e.g. bold), the dedup key and timestamp-alignment comparison still mismatch, producing duplicate messages in the conversation context. Add stripMarkdownFormatting to both surfaces so the formatting divergence is eliminated before the key/comparison is computed.
Summary: - Merged fix(telegram): dedupe visible assistant prompt context after ClawSweeper review. Automerge notes: - PR branch already contained follow-up commit before automerge: fix(telegram): align directive reply prompt timestamps Validation: - ClawSweeper review passed for head 5c4cc72. - Required merge gates passed before the squash merge. Prepared head SHA: 5c4cc72 Review: openclaw#100573 (comment) Co-authored-by: momothemage <[email protected]> Approved-by: momothemage
Fixes #99117.
Alternative to #100571 with a narrower dedupe key and handler/dispatch regression coverage.
AI-assisted: yes
What Problem This Solves
Fixes an issue where Telegram DM follow-up prompts could include the same assistant reply twice when the session transcript retained inline reply directives but the Telegram message cache contained the visible delivered text. The duplicated context made the assistant see both a synthetic
session:transcript row and the real Telegram cache row for the same reply.Why This Change Was Made
The shipped change keeps the existing timestamp-aligned dedupe boundary and normalizes body text through the same inline directive stripping used for delivery. The follow-up commit also applies the same delivery-visible comparison when copying the transcript timestamp into outbound Telegram prompt-context cache entries, so replies like
[[reply_to_current]]Final answerstill get the transcript timestamp even though Telegram receives onlyFinal answer.That lets the Telegram cache row win over the transcript-only row for the same delivered reply without merging repeated assistant messages that happen to have the same visible text at different times.
User Impact
Telegram DM follow-up prompts no longer repeat assistant replies just because transcript text still contains tags such as
[[reply_to_current]]. Prompt context stays closer to what the user actually saw in Telegram, while preserving distinct replies sent at different timestamps.Evidence
8a3b4c254911b47c97cf232bf633f2a54e6d615bfailed and showed the candidate still duplicated the hidden assistant context marker: fix(telegram): dedupe visible assistant prompt context #100573 (comment)5c4cc7245efixes the missing directive-aware timestamp handoff from transcript final text into outbound Telegram prompt-context cache rows.5c4cc7245ef0ea1bee514d41b48bc1aa0f44bf6a; manifest reportspass: trueand candidatefixed: true. Mantis did not generate before/after GIFs because this PR changes hidden Telegram conversation context rather than visible chat UI: https://artifacts.openclaw.ai/mantis/telegram-desktop/pr-100573/run-28773461514-1/index.json5c4cc7245ef0ea1bee514d41b48bc1aa0f44bf6aused the current sourcestripInlineDirectiveTagsForDeliveryhelper and the same directive-tagged assistant/cache inputs. It shows the directive-tagged session row and Telegram cache row produce the same timestamp-preserving key, the session-only duplicate is dropped, and the final hidden prompt context has exactly one visible assistant row:node scripts/run-vitest.mjs run extensions/telegram/src/bot.test.ts extensions/telegram/src/bot-message-dispatch.test.ts -t 'dedupes direct assistant transcript context|marks directive-tagged durable finals'- passed, 2 tests; 258 skippedpnpm lint:extensions:telegram-grammy-types- passedgit diff --check- passednode scripts/run-vitest.mjs run extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/bot.test.ts -t "prompt-context timestamp|stripping directives"- passednode scripts/run-vitest.mjs run extensions/telegram/src/bot-message-dispatch.test.ts extensions/telegram/src/bot.test.ts- passed, 260 testspnpm tsgo:test:extensions- passed