-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: Telegram prompt context includes duplicate assistant entries from session transcript + channel cache #99117
Copy link
Copy link
Closed
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.bugSomething isn't workingSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.bugSomething isn't workingSomething isn't workingclawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:session-stateSession, memory, transcript, context, or agent state can drift or corrupt.Session, memory, transcript, context, or agent state can drift or corrupt.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Type
Fields
Priority
None yet
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
In Telegram direct chats, the same assistant reply appears twice in prompt context — once from the session transcript (with a synthetic
#session:<id>id and[[reply_to_current]]directive tag) and once from the Telegram message cache — because the dedupe key uses exacttimestamp_ms:bodymatching that fails when the two copies differ in tags and timestamps.Steps to reproduce
[[reply_to_current]]#session:<id>assistant line containing the directive tag and a normal Telegram message id line with the same visible replyExpected behavior
Only one normalized assistant message should appear in prompt context for a given delivered reply, matching how the session transcript path already excludes
delivery-mirrorrows.Actual behavior
Conversation context included duplicate pairs such as:
#session:6325109d ... OpenClaw: [[reply_to_current]]Yep — I'm here now...#736 ... OpenClaw: Yep — I'm here now...and:
#session:697cdaed ... OpenClaw: [[reply_to_current]]Status looks good...#740 ... OpenClaw: Status looks good...The same assistant reply appears twice: once from session transcript history and once from Telegram-delivered history.
OpenClaw version
2026.6.11 (e085fa1)
Operating system
macOS 26.3.1 (Apple Silicon, arm64)
Install method
npm global install (npm i -g openclaw), gateway run as LaunchAgent
Model
openai/gpt-5.4
Provider / routing chain
Direct OpenAI API (api.openai.com/v1/responses), no proxy or router
Additional provider/model setup details
Single-agent setup, Telegram channel only. Node 25.8.0. Codex plugin disabled after it previously hijacked the runtime; current runtime is OpenClaw default with the OpenAI provider.
Logs
Screenshots, recordings, and evidence
Source analysis (bundled dist filenames from 2026.6.11; build hashes may differ, function names should be searchable):
dist/bot-CBwSxkGA.js:toSessionTranscriptPromptMessage(...)adds syntheticsession:<id>ids;buildTelegramSessionTranscriptPromptMessages(...); merge ofsessionPromptMessages+cachePromptMessages;resolvePromptContextTextDedupeKey(...)returnstimestamp_ms:bodydist/transcript-CSsWGO8o.js:parseRecentConversationText(...)excludes transcript-only assistant models;readRecentUserAssistantTextForSession(...)— delivery-mirror rows are already filtered, so this is not delivery-mirror leakageImpact and severity
[[reply_to_current]]#session:<id>ids visible in prompt contextAdditional information
Suggested fixes: (1) normalize assistant transcript text before dedupe (strip directive tags, normalize whitespace); (2) dedupe on normalized visible text rather than exact
timestamp_ms:body, or prefer cache entries over transcript entries when text is substantially identical; (3) avoid exposing transcript-only synthetic ids when a cache-backed equivalent exists.