Skip to content

[regression] delivery bundle emits message_sent hooks but never calls recordSentMessage #92242

Closed

Description

@saphoroth

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

  1. Install version 2026.6.5-beta.2 globally via npm.
  2. Configure one Telegram source-delivery channel and start a turn.
  3. Send a reply from the agent to a test chat.
  4. Inspect the Telegram sent-message ledger at the documented location
    (sessions.json's telegram-sent-messages array, or the equivalent
    public path the project uses).
  5. Observe: the ledger is NOT appended for the new message.
  6. Optionally, attach a debug hook that logs message_sent events
    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:

  1. Imports (modify the existing import, line ~31): add
    , i as recordSentMessage to the existing
    import { I as resolveTelegramReplyId, Y as resolveTelegramMediaPlaceholder } from "./sent-message-cache-PBe96Xkg.js";
    (the export is aliased as i in that module).

  2. deliverTextReply (line ~230): after sendTelegramText
    returns the messageId, call
    recordSentMessage(params.chatId, messageId, params.cfg).

  3. deliverMediaReply (line ~317): at each of the 5 media
    branches where result.message_id is captured, call
    recordSentMessage.

  4. sendTelegramVoiceFallbackText (line ~292): at the
    messageId return, call recordSentMessage.

  5. Joiner line in dist/bot-*.js: add cfg: cfg, to the
    const deliveryBaseOptions = { ... } literal (line ~6151) so
    params.cfg arrives defined at delivery-2y1J_O5Y.js:590 on
    the main-dispatch path. Without this, params.cfg is
    undefined and the new recordSentMessage calls 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.

Activity

  1. clawsweeper commented on Jun 11, 2026

    @clawsweeper
    Contributor

    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 main still routes successful automatic Telegram text and media replies through direct delivery helpers that return Telegram message IDs and emit message_sent hooks, 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 wasSentByBot for each returned ID; live execution was not needed to establish the source-level omission.

    Root-cause cluster
    Relationship: canonical
    Canonical: #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:

    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.ts so 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 wasSentByBot for 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:

    • The linked repair PR is currently reported as not cleanly mergeable and lacks real Telegram proof, so it should be rebased onto the current split delivery implementation and revalidated before landing.
    • A text-only repair would remain incomplete: the same missing write boundary exists for successful media and voice-fallback sends.

    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:

    • Current text-delivery path omits ledger recording: deliverTextReply receives a successful message ID from sendTelegramText, stores it only for delivery/projection bookkeeping, and then continues without calling recordSentMessage. (extensions/telegram/src/bot/delivery.replies.ts:267, 7bcbe743bd42)
    • Current media-delivery path omits ledger recording: The media helper receives a successfully delivered Telegram message, captures 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)
    • Ledger writer exists and is the canonical state owner: recordSentMessage stores 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)
    • Current tests do not cover the claimed boundary: The delivery test file contains no recordSentMessage or wasSentByBot assertion, so current regression coverage does not prove that successful automatic delivery writes the ledger. (extensions/telegram/src/bot/delivery.test.ts:1, 7bcbe743bd42)
    • Open implementation candidate already owns the repair: The supplied GitHub context identifies an open PR that explicitly closes this issue and targets source-delivery message-ID recording; it remains the canonical implementation path until reviewed, rebased, and merged. (20d3285e191c)
    • Current delivery-path provenance: A no-lazy-fetch blame pass attributes the currently inspected delivery helper lines to the current checkout commit; available local history is shallow, so this is routing evidence rather than a claim about original regression introduction. (extensions/telegram/src/bot/delivery.replies.ts:267, d585c0c1ec)

    Likely related people:

    • Peter Steinberger: The current checkout's blame output attributes the inspected text-delivery helper and its direct Telegram send boundary to this commit author; deeper origin history was unavailable from the partial local object store. (role: current delivery-path contributor; confidence: medium; commits: d585c0c1ec; files: extensions/telegram/src/bot/delivery.replies.ts)
    How this review workflow works
    • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
    • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
    • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
    • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
    • Maintainers can also comment @clawsweeper review to request a fresh review only.
    • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
    • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
    • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
  2. added
    P1High-priority user-facing bug, regression, or broken workflow.
    impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.
    impact:session-stateSession, 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.
    clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.
    clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.
    clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.
    on Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High-priority user-facing bug, regression, or broken workflow.clawsweeper:linked-pr-openClawSweeper found an open linked pull request for this issue.clawsweeper:no-new-fix-prClawSweeper does not recommend queueing a new automated fix PR for this issue.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.impact:message-lossChannel message delivery can be lost, duplicated, or misrouted.impact:session-stateSession, 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.

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions