Skip to content

fix: keep Telegram topic messages out of Home’s chat history - #208778

Merged
daniel-lxs merged 2 commits into
mainfrom
openclaw/telegram-topic-wrong-chat-9abc02
Nov 30, 2026
Merged

daniel-lxs merged 2 commits into
mainfrom
openclaw/telegram-topic-wrong-chat-9abc02

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #208750

What Problem This Solves

A Telegram message can reach the right forum topic but also appear in Home as a background result. When Home has a stale participant link for that topic, the group message can become part of Home’s next model request.

User Impact

New sends and queue recovery no longer copy that topic’s message into Home just because Home once had its address. Two distinct recoveries both reach the topic’s history. Genuine IRC DMs still enter Home’s history when the channel is configured to share it. This does not delete old transcript entries or repair stored links. There is no migration, config change, or schema, version, or SDK change.

Why This Change Was Made

A saved reply address is not proof that Home owns the chat. I preserve observed participants and matching caller pins. If a single group primary competes only with unobserved DM hints, I use it only when the channel confirms both its exact session key and its chat type. Two plausible owners still cause the history write to be skipped.

For a direct alias such as an IRC nick, the history writer now uses the same bounded rule as explicit delivery (#101507): the route and stored participant must agree on the configured Home key, DM scope must be shared-main, and no binding on that channel can isolate peers. An unresolved Telegram alias is not treated as a confirmed destination. This preserves the ownership decisions in #208049, #208130, and #208169. If a first inbound message races initial session creation, the stored reply address can still be refreshed; the destination transcript remains the topic.

Evidence

I compared main 0dd4e0a2a83 with 5b9d4cfe20af on CrabBox AWS. Both new regression tests also failed at the reported points on the previous PR head, 90347c97. I recreated the old Home association with the supported session writer and inspected SQLite histories rather than inferring ownership from a successful send.

Observable result Main Fix
Genuine shared-main IRC DM: confirmed recovery rows in Home 1 1
Two distinct recoveries to a new Telegram General session: rows in General / Home 0 / 2 2 / 0
Implicit General send with the topic in the target: extra delivery rows in Home 1 0
Recovery with the topic in the target and no separate thread: rows in General / Home 0 / 1 1 / 0

Each original Telegram case emitted exactly one send to General. The ordinary inbound-address control stayed out of Home, and ordinary recovery kept its single topic row. The new tests verify that an isolating IRC binding blocks the alias and that two genuine Telegram primaries do not acquire a third recovery row. Format, lint, production and test typechecks, and the focused consumer suites passed.

The Telegram proof uses OpenClaw’s message tool, Gateway handler and plugin with a loopback Bot API. The IRC test uses the monitor’s post-admission DM shape, real session initialization, bundled nick resolver and confirmed-recovery writer. Annotated and clean before/after Home screenshots.

I did not reproduce the original creation of the stale association or exercise a live IRC network. Live Telegram Test Server proof is also missing: the QA broker rejected credential acquisition before it leased a credential, created a forum or sent a message. This is a draft, not a release or merge recommendation.

Reported by @alexph-dev. Co-authored-by: @daniel-lxs.

Work sessions

Linked for team reference; these sessions aren’t public.

Worked on by

🦞 Made with OpenClaw

Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 8992fac2-78de-4411-8655-b83ba8e98c73
@clawsweeper

clawsweeper Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

🦞👀
Pull request received.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation size: S labels Nov 30, 2026
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Main vs fix: Telegram General send and Home’s next turn

I reproduced the send against a loopback Telegram Bot API on CrabBox AWS. The same Control UI and Gateway reader opened the main and fixed transcripts. Main showed the group reply in Home and included it in Home’s next model request. The fix did neither; the topic kept its own record. The four frames below show the same Home conversation, first annotated, then clean.

Before (annotated): Telegram topic reply appears in Home

After (annotated): only Home’s own reply remains

Before: main Home transcript

After: fixed Home transcript

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. labels Nov 30, 2026
@daniel-lxs

Copy link
Copy Markdown
Member

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

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. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Nov 30, 2026
@clawsweeper

clawsweeper Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: passed.

What this changes

The PR requires stronger destination evidence before recording confirmed Telegram topic sends in Home, while preserving genuine shared-main IRC DMs.

Example: A confirmed send targets telegram:-100123:topic:1 while Home retains an unobserved participant link for that address.

  • Before: The topic message can enter agent:main:main and Home’s next model request.
  • After: The channel-confirmed topic session receives the history entry, and Home receives none.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused destination-selection repair with concrete behavior evidence and no definite introduced defect; broader malformed-binding behavior remains outside its partial scope.
Proof confidence 🐚 platinum hermit (4/6) ✨ media proof bonus Sufficient (screenshot): The body reports before/after message-tool and Gateway runs using the bundled Telegram plugin with a loopback Bot API, transcript inspection, and recovery controls; inspected screenshots corroborate the Home-history result, while live Telegram and IRC coverage remains optional and absent.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Partial
User problem: Telegram topic messages appear in Home and become context for an unrelated conversation.
Reason: Preventing new wrong-transcript writes has clear value; the maintainer-authored direction is established, and Related wording correctly preserves the broader issue.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a current wrong-session history bug, introduces no definite correctness finding, and remains an explicitly paused draft.

Reviewed head: 5b9d4cfe20af88c25752aa4f8fb4f82fc3f6e32f

Before merge

None.

Findings

None.

Agent review details

How this fits together

Confirmed outbound sends and queue recovery enter the shared history writer, which combines recorded conversation bindings with channel-owned routes and appends the payload to the destination session.

flowchart TD
  A[Confirmed outbound send] --> C[Confirmed history writer]
  B[Queue recovery] --> C
  C --> D[Conversation registry]
  C --> E[Channel route resolver]
  D --> F[Destination session]
  E --> F
  F --> G[Model visible transcript]
Loading

Technical review

Best possible solution:

Keep destination selection in the shared confirmed-history owner and track malformed-link creation and historical cleanup in the linked issue.

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

Current-main source establishes the stale-participant selection path, and supplied Gateway evidence demonstrates its visible result; this read-only review ran no target code and does not establish the original association-creation sequence.

Is this the best way to solve the issue?

The fix appropriately distinguishes observed participants from reply hints at the shared destination owner, reuses the established alias contract, and preserves genuine ambiguity, but addresses only part of the linked report.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Confirmed-send destination ownership keeps the original intent (3fe7f1e: fix: messages sent to another chat are missing from that chat's model history #182329 centralized confirmed sends so messages enter the receiving chat’s model history once.)
  • Ambiguous delivery bindings changes intended behavior with a stated reason (fix: record an announced send in the chat it reached #208169: The earlier repair excluded non-chat hints while preserving ambiguity between genuine chat owners; this PR explains why one exact channel-confirmed group primary can outrank unobserved DM hints.)
  • Shared-main direct aliases keeps the original intent (a2a68d1: Explicit recipient routing preserves configured DM isolation and permits aliases only when the channel cannot isolate peers; the extracted helper retains that restriction.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +73, Tests +277, Docs +6. Total +356 across 7 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 123 50 +73
Tests 1 277 0 +277
Docs 1 8 2 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 408 52 +356

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Root-cause cluster

Relationship: partial_overlap
Canonical: #208750
Summary: The linked issue owns the broader malformed-conversation problem; this PR repairs its immediate confirmed-history destination path.

Members:

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

Labels

Label changes:

No label changes.

Label justifications:

  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence.

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 readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ 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-11-30T04:08:20.461Z sha 90347c9 :: passed. :: none

Reviewed November 29, 2026, 11:50 PM ET / November 30, 2026, 04:50 UTC (Revision 2).

Worked on by:
- @daniel-lxs

Co-authored-by: daniel-lxs <[email protected]>
OpenClaw-Publication: 457c3fc4-149c-4ce3-85de-cc0e253ca74b
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀

Re-review progress:

@daniel-lxs
daniel-lxs marked this pull request as ready for review November 30, 2026 05:01
@daniel-lxs
daniel-lxs merged commit 7c2cc20 into main Nov 30, 2026
206 checks passed
@daniel-lxs
daniel-lxs deleted the openclaw/telegram-topic-wrong-chat-9abc02 branch November 30, 2026 05:25
vincentkoc added a commit that referenced this pull request Nov 30, 2026
* commit 'b21f557c8fa038ebc1842e204e356eb063aea4c6': (46 commits)
  test(ui): keep real exports in the channel settings distribution mock (#208855)
  test(normalization): preserve inline code in quoted previews (#208857)
  fix(ci): restore adaptive priors across large repository trees (#208838)
  test(agents): cover typography preservation in patch updates (#208851)
  fix(ci): wait for selected agent during model setup proof (#208847)
  fix: keep Telegram topic messages out of Home’s chat history (#208778)
  fix(worktrees): name the session to restore and say agents can't (#208828)
  fix: tell an idle parent when a child result couldn't reach its chat (#208772)
  fix: keep the provider search focused when accounts load (#208780)
  fix(clawrouter): respect permitted speeds on model fallback (#208830)
  fix(ui): show provider rejection details without Markdown escapes (#208829)
  fix: make the cloud worker deletion test reliable across reconnects (#208812)
  fix(update): preserve preparation lock ownership (#207139)
  chore(release): update appcast for 2026.11.12 (#208820)
  fix(android): Talk does nothing when mic access is permanently denied (#206609)
  test(config): preserve media model primaries across repeated edits (#208837)
  fix(browser): use the mock keychain for new headed macOS profiles (#208814)
  fix: start source workers without synchronous filesystem reads in the caller (#208789)
  refactor(ios): stop loading retired Overview data (#208795)
  perf(knowledge): stop repeating write-input schemas in batch and correct tools (#208617)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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