Skip to content

fix(telegram): delivered group replies show Run failed when sent into a reply chain - #185899

Merged
obviyus merged 2 commits into
openclaw:mainfrom
moonbow0407:fix/185720-telegram-non-forum-reply-thread
Oct 27, 2026
Merged

obviyus merged 2 commits into
openclaw:mainfrom
moonbow0407:fix/185720-telegram-non-forum-reply-thread

Conversation

@moonbow0407

@moonbow0407 moonbow0407 commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Related to #185720.

What Problem This Solves

Fixes: a successful Telegram reply in an ordinary (non-forum) group can leave the session showing Run failed: Unknown error when the reply lands in an existing reply chain.

User Impact

Replies that the agent sends into a regular Telegram group, quoting the triggering message, now reconcile as delivered. The run no longer flips to a failed status after the message was actually sent. Forum-topic and DM-topic sends keep their existing wrong-topic checks.

Why This Change Was Made

In non-forum groups Telegram also sets message_thread_id on messages that belong to a reply chain, pointing at the chain's root message. Inbound routing already treats that as scope: "none" (resolveTelegramMessageThreadSpec), but the outbound provider-proof path promoted the same field to receipt.threadId. Core source-reply reconciliation then compared that thread ID against the unthreaded source conversation, saw a mismatch before checking the matching replyToId, and the pending-terminal cleanup marked the run failed without an error.

The provider-observed thread is now ignored for unthreaded sends when the response carries no forum proof (is_topic_message / chat.is_forum), reusing the existing resolveTelegramMessageForumFlagHint owner. Sends that requested a topic are unchanged, so a real wrong-topic delivery still fails loudly and keeps its receipt.

Not in scope: the issue also notes that an ambiguous terminal delivery is recorded without a lastRunError. That core cleanup path is separate; this PR fixes the producer that created the false mismatch.

Evidence

#185899 (comment) — real Telegram Test Server reply chains: main visibly delivers both replies but persists failed / abortedLastRun:true; candidate visibly delivers both and persists done / abortedLastRun:false. Actual Bot API fields, stored tool receipts, shared reconciliation signals and public session status are recorded. Non-chain and genuine forum-topic controls pass on both refs.

The model is a deterministic local fixture; Telegram delivery and persisted status are real. Verified ordinary and forum fixtures are deleted, leases released, credential scratch removed, and consumers joined. No rendered Control UI claim is made.

Regression repair: the existing durable registered-send table now covers requested topics, non-forum chains and forum proof without net test growth (0 lines). 142 focused tests passed, final HTTP table 32/32, scoped formatting/lint passed. Production is unchanged after the live proof. Earlier contributor loopback red/green receipt results remain supporting unit evidence, not a substitute for this Test Server run.

Merge danger: a two-way code change with no schema/config migration. Blast radius is Telegram provider receipt classification for unrequested group reply chains; requested-topic and Direct Messages checks remain strict. Genuinely ambiguous-delivery diagnostics remain outside this partial fix.

…replies

Telegram sets message_thread_id on reply chains in ordinary groups. The outbound provider proof promoted it to receipt.threadId for unthreaded sends, so source-reply reconciliation saw a topic mismatch and marked the delivered run failed. Require forum proof before reporting a provider thread when no topic was requested.

Closes openclaw#185720
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: S labels Oct 27, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 27, 2026
@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

The PR excludes ordinary group reply-chain IDs from topic receipts when no topic was requested and Telegram provides no forum evidence.

Example: Telegram accepts message 7 replying to message 6 in an ordinary group, with reply-chain root 4.

  • Before: The receipt includes threadId 4, causing the delivered run to finish failed with abortedLastRun true.
  • After: The receipt preserves replyToId 6 without a topic ID, and the run finishes done with abortedLastRun false.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch and shipped-entry-point proof are strong; the overall tier reflects partial coverage of the linked issue's broader diagnostic request.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied Test Server output exercises the real message tool, Telegram transport, Gateway reconciliation, and persisted/public session status for two ordinary reply chains, with top-level and forum controls; only model output is deterministic, and production is unchanged at the final test-only head.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: A visibly delivered Telegram group reply leaves its session showing Run failed: Unknown error.
Reason: The demonstrated false-failure path is fixed; the linked issue's separate request for explanations of genuinely ambiguous terminal delivery remains explicitly deferred.

Merge readiness

✅ Ready for maintainer review

This PR repairs a confirmed Telegram receipt-classification bug without weakening requested-topic validation; the earlier proof and test-growth blockers are resolved.

Priority: P2
Reviewed head: a9a2e246da87ece85fa0b439a0facc39a7af5003

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A red-on-base/green-on-head execution of the final consolidated regression table is not shown; the supplied live before-and-after Gateway scenario proves the changed behavior.
Agent review details

How this fits together

Telegram's outbound adapter converts accepted Bot API messages into delivery receipts consumed by shared source-reply reconciliation and session completion.

flowchart LR
  A[Telegram message tool] --> B[Bot API send]
  B --> C[Accepted Telegram message]
  C --> D[Telegram receipt classification]
  D --> E[Source reply reconciliation]
  E --> F[Persisted session status]
Loading

Technical review

Best possible solution:

Land the focused Telegram producer correction after required checks pass, retaining the separate diagnostic follow-up for genuinely ambiguous delivery.

Do we have a high-confidence way to reproduce the issue?

Current-main source establishes the mismatch, and the supplied real Telegram/Gateway before-and-after output reproduces its persisted-status consequence on pinned revisions.

Is this the best way to solve the issue?

Correcting receipt classification at the Telegram producer is the smallest complete repair for false failures and preserves shared reconciliation and strict requested-topic checks.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against d3b86610df08.

Provenance checked

  • Accepted-message topic classification keeps the original intent (5a8c27c: Use provider-observed placement to reject wrong-topic delivery and preserve partial-delivery evidence.)
  • Direct Messages topic namespace keeps the original intent (d7133e7: Keep channel Direct Messages topics distinct from forum and bot-private thread IDs.)
  • Registered-adapter regression coverage keeps the original intent (refactor(telegram): remove redundant test coverage #155040: Consolidate redundant Telegram tests while preserving distinct transport, ordering, authorization, and recovery contracts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Lu Wang: Raw commit 5a8c27c adds extensions/telegram/src/provider-thread-proof.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5a8c27ca41fa; files: extensions/telegram/src/provider-thread-proof.ts)
  • Peter Steinberger: Raw commit d7133e7 adds extensions/telegram/src/provider-thread-proof.ts:14 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: d7133e7df6f5; files: extensions/telegram/src/provider-thread-proof.ts)
  • Ayaan Zaidi: Raw commit 6c3a779 adds extensions/telegram/src/outbound-adapter.telegram-http.test.ts:58 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6c3a7799dc62; files: extensions/telegram/src/outbound-adapter.telegram-http.test.ts)

PR surface

Source +25, Tests 0. Total +25 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 27 2 +25
Tests 1 57 57 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 84 59 +25

Review metrics

Metric Value Why it matters
Production versus test LOC Production +27/-2; tests +57/-57 The production growth reuses the existing forum-evidence owner, and the regression extends an existing transport table without net test growth.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #185720
Summary: This PR repairs the canonical issue's ordinary-group receipt mismatch while leaving genuinely ambiguous-delivery diagnostics outside its scope.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🧂 unranked krab: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: A bounded Telegram reply path reports successful delivery as a failed session and can encourage unnecessary retries.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-27T13:14:42.561Z sha 46b70ad :: needs real behavior proof before merge. :: [P2] [P2] Resolve the regression's test-line ratchet failure

Reviewed October 27, 2026, 2:47 PM ET / 18:47 UTC (Revision 2).

@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Real Telegram Test Server delivery + persisted run-status proof

Candidate production 46b70ad5dc579ba6e0d00d190140ebb8228f3b8d; pinned main eb78444932faeff3e6ab23d082e6c02dc0ddcb2b. Both refs built successfully in fresh secretless Linux Node24.22.1 containers. The repo's telegram-e2e-userbot runner drove the leased real user, real Telegram Test Server Bot API, built Gateway and native OpenClaw runtime with a deterministic local Responses provider.

The user creates a root → middle → triggering-message reply chain in a verified non-forum supergroup. The provider instructs the real message tool to send the terminal source reply (final:true). No Telegram response/receipt, shared reconciler or session state is mocked or rewritten. Raw accepted Bot API fields are captured passively after normal JSON parsing; stored tool results, public sessions.list and read-only persisted session rows provide independent downstream evidence.

All message identifiers below are local to separate run-owned Test Server chats; private group/user/bot identities are omitted.

Case Telegram accepts / QA user sees Actual action receipt Persisted and public run status
Main chain1 Message7, reply to6, ordinary chain thread4 threadId:"4", replyToId:"6" failed, abortedLastRun:true, error explanation absent
Main chain2 Message11, reply to10, ordinary chain thread8 threadId:"8", replyToId:"10" failed, abortedLastRun:true, error explanation absent
Candidate chain1 Message7, reply to6, same provider thread4 replyToId:"6", no threadId done, abortedLastRun:false
Candidate chain2 Message11, reply to10, same provider thread8 replyToId:"10", no threadId done, abortedLastRun:false

Each chain is a distinct run, with a separately recorded lastRunId. TDLib independently records both delivered CHAIN_REPLY185899 messages on both refs, using messageTopicThread for the ordinary reply chains. Main logs Terminal source reply receipt was not mirrored; restart recovery is fail-closed. Candidate's stored successful tool result instead records sourceReplyRoute:"current-source" and messageDelivery:{status:"settled", sourceReplyDelivered:true} before the session remains done. This proves delivered-but-failed status, not a missing receipt or missing message.

Controls

  • Non-chain/top-level control: native tool send with topLevel:true delivers message13 without a Bot API conversation-thread field; both refs finish done / abortedLastRun:false. On main this next ordinary request clears the earlier failed status without restart, reset or direct state repair.
  • Genuine forum-topic control on both refs: Telegram confirms is_forum:true; message5 carries is_topic_message:true, message_thread_id:3, reply to4. Both receipts preserve threadId3 / replyToId4, TDLib records messageTopicForum topic3, and persisted/public status is done / abortedLastRun:false.
  • Existing requested-topic mismatch refusal, private-topic and channel Direct Messages namespace controls remain in the focused suites.

Fixture, evidence and cleanup limits

The ordinary fixtures are creator-owned Test Server supergroups: the existing run-owned forum fixture creates/upgrades the group, then a real TDLib operation disables forum mode. Both TDLib and Bot API readback confirm ordinary supergroup / is_forum:false before the chain runs; no forum-topic selector is sent. A basic-group attempt lacked the discriminating thread metadata and is not counted as reproduction. Earlier harness schema/import/readback/heartbeat setup failures are preserved but excluded from product conclusions. Final ordinary and forum recordings are complete, every scenario action completes, and every run-owned group is confirmed deleted before lease release. Private credential scratch is removed and all runner-owned consumers are joined.

The only simulated component is model output. Telegram transport, accepted message metadata, source-reply reconciliation and persisted/public status are real. The API observer returns the parsed value unchanged. This is not a rendered Control UI screenshot claim or a repair for genuinely ambiguous-delivery diagnostics. Test Server acknowledgement reactions can return REACTION_INVALID on both refs; the text sends are accepted and the controls distinguish the receipt/status defect independently.

Non-growing regression repair

Head a9a2e246da87ece85fa0b439a0facc39a7af5003 preserves the contributor commit and changes only the existing registered-adapter HTTP suite: requested-topic, non-forum-chain and forum-proof receipts share the durable-before-HTTP table. Existing reaction, media, edit and queue contracts remain; redundant type/configuration scaffolding is consolidated. Whole-PR test-line delta is 0 (57 added /57 removed); production stays +27/-2 (net+25). No global budget or unrelated tests change, and the live production proof carries unchanged.

Observed focused checks: 142 tests passed across5 files, including wrong-topic and namespace controls; the final HTTP table was rerun 32/32 after its last fixture-only trim. Scoped Oxfmt/Oxlint passed. Hosted CI and review must evaluate the repaired head; no prior red is claimed green.

@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 27, 2026
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Final consolidated-table negative control (source head unchanged): copied the exact committed HTTP regression table onto pinned unfixed main eb78444932faeff3e6ab23d082e6c02dc0ddcb2b in its isolated container. The requested-topic and forum-proof rows pass, while only the non-forum reply-chain row fails with expected ['99','456'] to deeply equal [undefined,'456']. The same committed table passes all three rows on the candidate as part of the final32/32 HTTP suite. This directly supplies the final-table red-on-base/green-on-head evidence noted in the review; no product/test changes or new push.

@obviyus
obviyus merged commit 32075f3 into openclaw:main Oct 27, 2026
119 of 120 checks passed
@obviyus

obviyus commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

Landed in 32075f3. Thanks @moonbow0407. Delivered Telegram reply-chain replies no longer show Run failed.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 28, 2026
… a reply chain (openclaw#185899)

fix(telegram): don't mark delivered group replies in a reply chain as failed

In a non-forum Telegram group, a reply sent into a reply chain was delivered, but the run was saved as failed (abortedLastRun true), so the UI showed "Run failed". The delivery receipt now matches the reply-chain thread fields, so the run is recorded as done.

Evidence: real Telegram Test Server groups. On main both reply-chain responses were visibly delivered but saved as failed with abortedLastRun true; with this change both were delivered and saved as done with abortedLastRun false. Non-chain replies and genuine forum topics behave the same on both refs. Details: openclaw#185899 (comment). Ambiguous-delivery diagnostics are not addressed here.

Thanks @moonbow0407.

Co-authored-by: Ayaan Zaidi <[email protected]>
RomneyDa added a commit that referenced this pull request Oct 28, 2026
… a reply chain (#185899)

fix(telegram): don't mark delivered group replies in a reply chain as failed

In a non-forum Telegram group, a reply sent into a reply chain was delivered, but the run was saved as failed (abortedLastRun true), so the UI showed "Run failed". The delivery receipt now matches the reply-chain thread fields, so the run is recorded as done.

Evidence: real Telegram Test Server groups. On main both reply-chain responses were visibly delivered but saved as failed with abortedLastRun true; with this change both were delivered and saved as done with abortedLastRun false. Non-chain replies and genuine forum topics behave the same on both refs. Details: #185899 (comment). Ambiguous-delivery diagnostics are not addressed here.

Thanks @moonbow0407.

Co-authored-by: Ayaan Zaidi <[email protected]>

(cherry picked from commit 32075f3)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 663c7ee9ab7afc08aee5dbb62533e778ff86b531)
RomneyDa added a commit that referenced this pull request Oct 28, 2026
… a reply chain (#185899)

fix(telegram): don't mark delivered group replies in a reply chain as failed

In a non-forum Telegram group, a reply sent into a reply chain was delivered, but the run was saved as failed (abortedLastRun true), so the UI showed "Run failed". The delivery receipt now matches the reply-chain thread fields, so the run is recorded as done.

Evidence: real Telegram Test Server groups. On main both reply-chain responses were visibly delivered but saved as failed with abortedLastRun true; with this change both were delivered and saved as done with abortedLastRun false. Non-chain replies and genuine forum topics behave the same on both refs. Details: #185899 (comment). Ambiguous-delivery diagnostics are not addressed here.

Thanks @moonbow0407.

Co-authored-by: Ayaan Zaidi <[email protected]>

Beta.5 baseline adaptation: Retain the native beta.5 owners, fixtures and public contracts; add focused regression controls and bounded fixture extraction; apply checkout formatting.

(cherry picked from commit 32075f3)

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 513da19202ff3e7951236a1453737d09eda91113)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants