Repository navigation
Description
Summary
The automatic source-delivery bundle in 2026.6.5-beta.2 emits the
message_sent hook for every successful send, but never records the
message into the sent-message ledger. This regresses the original fix
from the prior bundle (which was lost when the bundle was renamed) and
re-opens the "Message failed" symptom class for any user relying on
ledger persistence for reaction filters, reply-to routing, or
wasSentByBot checks.
Version / Environment
- Project version: 2026.6.5-beta.2 (and 2026.6.5 stable; possibly
earlier 2026.6.5-beta.x — beta.2 is the install under test) - Install method: npm global
- OS: Linux x64 (tested; macOS/Windows likely affected too — the
defect is in the dist bundle, not platform-specific) - Runtime: Node.js (any LTS supported by the project)
- Relevant configuration: a single Telegram source-delivery channel
(the delivery bundle is invoked for every automatic reply; the bug
is independent of the model used)
Steps to Reproduce
- Install version 2026.6.5-beta.2 globally via npm.
- Configure one Telegram source-delivery channel and start a turn.
- Send a reply from the agent to a test chat.
- Inspect the Telegram sent-message ledger at the documented location
(sessions.json'stelegram-sent-messagesarray, or the equivalent
public path the project uses). - Observe: the ledger is NOT appended for the new message.
- Optionally, attach a debug hook that logs
message_sentevents
and confirm the hook IS fired (i.e., the dist tells plugins a
message was sent, but does not record the send itself).
Expected Behavior
The sent-message ledger is appended with a new entry for each
successfully-sent message — {chatId, messageId, scopeKey, timestamp, cfg} or the project's equivalent ledger shape. This is the behavior
the prior bundle (delivery-*.js in 6.5-beta.1 and earlier) had
after the original fix.
Actual Behavior
The message_sent hook is fired (you can confirm by listening for it),
but the dist's own ledger write is bypassed. The bundle has zero
recordSentMessage calls. Sent-message persistence is therefore
broken for automatic source-delivery; wasSentByBot checks return
false for every main reply; reaction filters mis-fire; reply-to
routing that depends on the ledger misses legitimate sends.
Impact
Affects every user of automatic source-delivery on the affected
version. Severity: HIGH for delivery-observability and reaction
filtering. Detection: silent — no error is surfaced to the user or
to a plugin listener. The original fix in the prior delivery bundle
explicitly addressed this symptom class; the regression re-opens
it.
Evidence
From the affected dist bundle dist/delivery-2y1J_O5Y.js:
The emitMessageSentHooks function (around line 550) builds a
canonical context and fires both runMessageSent (the plugin hook)
and triggerInternalHook("message", "sent", ...) (the internal
hook), but does NOT call recordSentMessage:
function emitMessageSentHooks(params) {
if (!params.enabled && !params.sessionKeyForInternalHooks) return;
const canonical = buildTelegramSentHookContext(params);
if (params.enabled) fireAndForgetHook(
Promise.resolve(params.hookRunner.runMessageSent(
toPluginMessageSentEvent(canonical),
toPluginMessageContext(canonical)
)),
"telegram: message_sent plugin hook failed"
);
emitInternalMessageSentHook(params);
}
Grepping the bundle for recordSentMessage returns 0 matches. By
contrast, the prior bundle (the one renamed to delivery-2y1J_O5Y.js
in 6.5-beta.2) had the original fix applied — the call
sites at deliverTextReply, deliverMediaReply (5 sites), and
sendTelegramVoiceFallbackText were all wired to call
recordSentMessage after each successful send. The rename lost
the patch.
The hook contract is preserved (the dist still fires message_sent
events), so plugins that listen for the hook can still observe sends
— but the dist's own ledger write is missing.
Suggested Fix
A targeted forward-port of the original fix into
delivery-2y1J_O5Y.js:
-
Imports (modify the existing import, line ~31): add
, i as recordSentMessageto the existing
import { I as resolveTelegramReplyId, Y as resolveTelegramMediaPlaceholder } from "./sent-message-cache-PBe96Xkg.js";
(the export is aliased asiin that module). -
deliverTextReply(line ~230): aftersendTelegramText
returns the messageId, call
recordSentMessage(params.chatId, messageId, params.cfg). -
deliverMediaReply(line ~317): at each of the 5 media
branches whereresult.message_idis captured, call
recordSentMessage. -
sendTelegramVoiceFallbackText(line ~292): at the
messageIdreturn, callrecordSentMessage. -
Joiner line in
dist/bot-*.js: addcfg: cfg,to the
const deliveryBaseOptions = { ... }literal (line ~6151) so
params.cfgarrives defined atdelivery-2y1J_O5Y.js:590on
the main-dispatch path. Without this,params.cfgis
undefined and the newrecordSentMessagecalls would record
into the default bucket.
Verifier check (post-fix): grep -c "recordSentMessage" delivery-2y1J_O5Y.js should be ≥ 7 (1 import + 1 text + 5 media +
1 voice-fallback).
Related Issues / PRs
None found at the time of writing. The defect appears to be a
regression introduced by the 2026.6.5-beta.2 bundle rename
(the affected file is dist/delivery-2y1J_O5Y.js, a rename of
the prior delivery bundle whose sent-message ledger recording
was not carried forward into the new bundle). A related closed
issue for the same symptom class in the dashboard picker is
#81837; the same fix pattern may apply.
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity
clawsweeper commentedon Jun 11, 2026
Codex review: keeping this open for maintainer follow-up; there is still a little grit to resolve. Reviewed August 1, 2026, 11:29 AM ET / 15:29 UTC.
Summary
Keep open: current
mainstill routes successful automatic Telegram text and media replies through direct delivery helpers that return Telegram message IDs and emitmessage_senthooks, but do not call the sent-message ledger writer. An open linked repair PR already owns this narrow regression, so the safe next step is to refresh and prove that repair rather than create a competing fix.Reproducibility: yes. from current source: successful text and media delivery paths expose returned Telegram message IDs but contain no call to the existing ledger writer. A focused regression can mock successful sends and assert
wasSentByBotfor each returned ID; live execution was not needed to establish the source-level omission.Root-cause cluster
Relationship:
canonicalCanonical: #92242
Summary: Current source confirms the issue's specific missing ledger-write boundary; the open linked repair is the sole viable candidate fix, while closed unmerged alternatives are not canonical replacements.
Members:
fixed_by_candidate: fix(telegram): record source-delivery message ids #92420 - This open PR explicitly targets source-delivery sent-message recording and is linked with closing syntax, but has not merged and still needs current-head proof.superseded: fix(telegram): restore sent-message ledger writes for delivery replies #92310 - This earlier repair attempt is closed unmerged and cannot replace the active repair candidate.superseded: fix(telegram): record every sent message in the SQLite db #93148 - This closed unmerged attempt addressed the same ledger symptom but is not a safe landing path.adjacent_distinct: Define durable final fallback delivery semantics across channels #87561 - That issue covers a broader cross-channel durable final-delivery contract; this issue is a concrete Telegram sent-message-ledger write omission.Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.
Next step
Do not queue a competing repair: #92420 already explicitly owns the implementation path and should be refreshed and reviewed first.
Review details
Best possible solution:
Update the open repair against current
extensions/telegram/src/bot/delivery.replies.tsso every successful direct source-delivery send records the returned message ID in the correctly scoped ledger, then add focused text, media, and voice-fallback regression coverage plus redacted real Telegram proof.Do we have a high-confidence way to reproduce the issue?
Yes, from current source: successful text and media delivery paths expose returned Telegram message IDs but contain no call to the existing ledger writer. A focused regression can mock successful sends and assert
wasSentByBotfor each returned ID; live execution was not needed to establish the source-level omission.Is this the best way to solve the issue?
Yes, the proposed repair direction is the right boundary: record only after each successful transport send, using the existing scoped ledger writer. It should be refreshed for the current split delivery modules and cover all successful text, media, and voice-fallback paths rather than forward-porting an obsolete bundle edit.
AGENTS.md: found and applied where relevant.
Remaining risk / open question:
Codex review notes: model internal, reasoning high; reviewed against 7bcbe743bd42.
Label changes
Label justifications:
P1: Successful Telegram replies can become invisible to reply/reaction logic on every affected automatic source-delivery turn, making this an urgent channel workflow regression.impact:message-loss: The affected sent-message ledger omits successfully delivered outbound messages, causing downstream delivery-related checks to treat them as absent.impact:session-state: Bot-origin and reply-routing decisions depend on the persisted sent-message state that this path fails to record.Evidence reviewed
What I checked:
deliverTextReplyreceives a successful message ID fromsendTelegramText, stores it only for delivery/projection bookkeeping, and then continues without callingrecordSentMessage. (extensions/telegram/src/bot/delivery.replies.ts:267, 7bcbe743bd42)message.message_id, updates prompt context and delivery state, but does not persist it to the sent-message ledger. (extensions/telegram/src/bot/delivery.replies.ts:368, 7bcbe743bd42)recordSentMessagestores the chat/message pair in the scoped in-memory bucket and persists an individual TTL-backed ledger entry; the missing behavior is a call-site gap, not a missing ledger facility. (extensions/telegram/src/sent-message-cache.ts:195, 7bcbe743bd42)recordSentMessageorwasSentByBotassertion, so current regression coverage does not prove that successful automatic delivery writes the ledger. (extensions/telegram/src/bot/delivery.test.ts:1, 7bcbe743bd42)extensions/telegram/src/bot/delivery.replies.ts:267, d585c0c1ec)Likely related people:
extensions/telegram/src/bot/delivery.replies.ts)How this review workflow works
@clawsweeper re-reviewcomments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.@clawsweeper re-reviewor@clawsweeper re-runon an open PR or issue to request a fresh review only.@clawsweeper reviewto request a fresh review only.@clawsweeper autofix,@clawsweeper automerge,@clawsweeper fix ci, or@clawsweeper address review.@clawsweeper explainto ask for more context, or@clawsweeper stopto stop active automation.