Skip to content

fix(telegram): preserve shared contact details in messages - #144602

Merged
obviyus merged 6 commits into
openclaw:mainfrom
JamesY023:lane/oc-contact
Oct 14, 2026
Merged

obviyus merged 6 commits into
openclaw:mainfrom
JamesY023:lane/oc-contact

Conversation

@JamesY023

@JamesY023 JamesY023 commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users sharing a Telegram contact card would receive no response because the incoming message had no text or media body. Replies to contact cards also lost their name and phone number.

Why This Change Was Made

Project contact fields through Telegram's existing inbound text owner. Keep contact-derived text out of mention admission, including after forwarding coalesces several messages: mention facts come from each original eligible segment, while all segments remain available as model content. This preserves genuine text mentions regardless of whether a contact comes first or last.

Thanks to @JamesY023 for the report and original fix; their commits are preserved. No overlap with Pash/Sarah changes.

User Impact

Users can share contacts without retyping their fields. Contact names and phone numbers do not become sender identity or authorization, and cannot activate a mention-required group. Text, caption, poll, reply, and participant-mention behavior remains covered by the adjacent suites.

Evidence

Current candidate: 111c4374a1aa4435ceda062d90e38f7079defa90. The contact DM/reply and four forwarded-batch results below were captured on 3fb2048c2d4d25fdc411385ac9fb336dded6b5b9 and are retained with that provenance. The final repair only gates per-segment mention reconstruction on the presence of a contact; that contact-bearing branch is unchanged. The new ordinary-fragment control and real-provider contact gate were run on a build of 111c4374a1aa, with no subsequent production change or contributor merge.

Real Telegram Test Server proof used a Convex-leased TDLib user and built Gateway. Native inputMessageContact contained synthetic name ContactProbe Q7 and phone +15550100001; the recorder observed messageContact.

Action Base 55cdb94fc8ba Contact candidate 3fb2048c2d4d
Share contact in DM No contact-triggered agent request or reply during the 15-second isolated window Provider received [Shared contact] ContactProbe Q7, +15550100001; Telegram reply at 5.897 s
Reply to that contact at 15 s Reply text reached the model without contact fields Provider retained [Replying to: "[Shared contact] ContactProbe Q7, +15550100001"]; reply at 16.887 s
Ordinary text control at 30 s Reply at 31.879 s Reply at 31.885 s

The DM scenario produced 2 agent-model requests / 2 replies on base, versus 3 / 3 on 3fb2048c2d4d. Background embedding/activity requests are excluded. Contact receipt: user-observed TDLib message ID 94923390976; first bot reply: 94924439552.

Forwarded-batch mention admission

A proof-only driver extension created bot-authored source messages, then the real user forwarded each text/contact pair together into a mention-required group. TDLib confirmed forward_info on all eight forwarded messages. Source fixtures were deleted afterward. The contact name was @<leased-bot-username> in every pair.

Forwarded order and genuine text Completed action Observed result
Text “hello”, then bot-name contact 2.530 s No agent turn or reply
Bot-name contact, then text “hello” 17.638 s No agent turn or reply
Bot-name contact, then genuine @bot text 32.780 s One coalesced agent turn; reply at 37.028 s
Genuine @bot text, then bot-name contact 47.522 s One coalesced agent turn; reply at 49.147 s

There were exactly 2 agent requests / 2 replies across these four bursts. Each positive request's authored input contained both the contact projection and its matching genuine text segment. The production-forwarding-buffer regressions failed on the prior head in opposite ways (text-first falsely admitted; contact-first suppressed the real mention), then both passed after the repair. A separate discrete bot-name contact/explicit-mention control also passed before the batch repair.

Preserve ordinary long-paste reassembly

The last repair restricts original-segment mention reconstruction to batches that contain contacts. Contact-free batches continue checking the existing assembled message, preserving the separator-free long-paste behavior from #155842.

The new registered-handler regression sends a 4096-character first fragment ending in @open, then claw_bot help, with no mention entities. It fails on 3fb2048c2d4d (zero admitted turns) and passes on 111c4374a1aa (one turn with byte-for-byte assembled input). Both forwarded-contact order regressions also pass on 111c4374a1aa.

A focused real Test Server control on 111c4374a1aa sent two ordinary text fragments of 4096 and 42 characters, splitting the leased bot's handle. TDLib observed both fragments, the model received one assembled input containing the continuation marker, and the group received one reply at 6.433 s. This control changes no contact fixture or larger proof scenario.

Real provider and focused checks

On the exact current candidate 111c4374a1aa, repeated the native contact DM through OpenAI gpt-5-mini, low reasoning. The provider request contained the contact projection; TDLib observed a real reply at 10.631 s (“I'm your new assistant here — what would you like me to call?”). The scoped key file was deleted and the channel lease released.

Sanitized forwarded-batch invocation (3fb2048c2d4d):

PROOF_PROFILE=p144602cand NODE_OPTIONS="--experimental-loader=$PROOF_DIR/proof-loader.mjs" \
  E2E_REQUIRE_MENTION=true \
  node "$TELEGRAM_E2E_SKILL_DIR/scripts/run-mock-sut-user-e2e.mjs" \
  --gateway-port 24465 --mock-port 24466 --timeout-ms 70000 \
  --scenario "$PROOF_DIR/batch-scenario.json" \
  --record "$PROOF_DIR/batch/events.ndjson" --output "$PROOF_DIR/batch/summary.json"

The focused 111c4374a1aa split-fragment invocation uses the same profile, loader, group and ports, with --timeout-ms 30000 --scenario "$PROOF_DIR/fragment-only.json" --record "$PROOF_DIR/fragment-live/events.ndjson" --output "$PROOF_DIR/fragment-live/summary.json".

The proof loader supplies only the host-owned leased payload and proof-only TDLib actions. No harness changes are included in the product diff.

The full body-admission and bot/forwarding suites and hosted CI passed on 3fb2048c2d4d. On 111c4374a1aa, the targeted split-handle and two forwarded-contact regressions, changed-file Oxfmt/Oxlint, and supported runtime-only build passed. Earlier contact/reply/forwarding proof is reused with its original SHA above rather than represented as a new run. Existing buffered-message facts supply mention provenance without a new API or state owner. Production delta: +32/-5 (net +27); tests: +132/-0. All production changes stay within Telegram.

Merge danger: two-way door; reverting restores the previous behavior without a schema or configuration migration. Blast radius is Telegram inbound contact/reply projection and mention admission; other channels are unchanged.

@clawsweeper

clawsweeper Bot commented Sep 11, 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 Sep 11, 2026
@JamesY023
JamesY023 marked this pull request as ready for review September 11, 2026 02:57
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 11, 2026
@clawsweeper

clawsweeper Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Preserves shared contact names and phone numbers in Telegram agent input and reply context while excluding those fields from group mention detection.

Example: Share ContactProbe Q7 with phone +15550100001 in an authorized Telegram DM.

  • Before: The contact produces no agent turn, and replying to it omits its contact details.
  • After: The agent receives “[Shared contact] ContactProbe Q7, +15550100001”, and subsequent reply context retains those details.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A useful, focused repair with shipped-entry-point proof, distinct regression coverage, and all prior findings resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The complete body records real-user TDLib contact updates through a built Gateway to provider requests and Telegram replies, contact reply-context retention, and forwarded text/contact pairs with both allowed and rejected mention controls on 3fb2048; the final diff preserves that contact-bearing branch, and exact-head 111c437 live runs prove split-handle reassembly and a real-provider contact response.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Sharing a Telegram contact card receives no response, and replying to that card loses its name and phone number.
Reason: The focused repair prevents silent loss of ordinary native message content while retaining existing sender authorization and mention behavior.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete Telegram message-loss bug that remains on current main; the prior mention-admission findings are addressed, with sufficient live proof and no remaining actionable finding.

Priority: P2
Reviewed head: 111c4374a1aa4435ceda062d90e38f7079defa90

Before merge

None.

Findings

None.

Agent review details

How this fits together

Telegram updates pass through the plugin’s ingress and batching owners into body admission and reply-context construction, which produce policy-admitted agent input and Telegram responses.

flowchart TD
  A[Telegram updates] --> B[Ingress and sender policy]
  B --> C[Inbound batching]
  C --> D[Text and contact projection]
  C --> E[Original message mention facts]
  D --> F[Body admission and reply context]
  E --> F
  F --> G[Agent turn and Telegram reply]
Loading

Technical review

Best possible solution:

Land the focused contact projection and mention-isolation repair through the normal landing gates.

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

Current-main source shows contact-only messages produce neither projected text nor media and are dropped; the supplied baseline Test Server run independently records no contact-triggered turn, while ordinary text succeeds.

Is this the best way to solve the issue?

The patch fixes the canonical Telegram text owner, reuses it for replies and batching, and keeps contact-derived content separate from mention facts without introducing another API or state owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +27, Tests +132. Total +159 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 32 5 +27
Tests 2 132 0 +132
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 164 5 +159

Review metrics

Metric Value Why it matters
Production versus test LOC Production +32/-5; tests +132/-0 Growth adds contact projection and distinct admission, forwarded-order, reply-context, and long-paste regressions through existing owners.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; 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: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 message-delivery: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Shared contact cards are silently omitted from Telegram agent input and reply context, with a limited channel-specific blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; 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.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Contact-triggered replies, contact reply context, and group mention admission are Telegram-visible; the supplied Test Server evidence exercises these behaviors.

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 (4 earlier review cycles)
  • reviewed 2026-09-11T03:04:20.568Z sha b6f6602 :: needs real behavior proof before merge. :: [P2] Exclude contact fields from mentions after batching
  • reviewed 2026-09-26T01:57:18.509Z sha b6f6602 :: needs real behavior proof before merge. :: [P2] Exclude batched contact text from group mention checks
  • reviewed 2026-10-14T06:00:20.845Z sha fb1dae6 :: needs real behavior proof before merge. :: [P2] Preserve contact mention isolation through forwarded batches
  • reviewed 2026-10-14T06:34:23.233Z sha 3fb2048 :: needs changes before merge. :: [P2] Preserve assembled mentions in ordinary long-paste batches

Reviewed October 14, 2026, 3:25 AM ET / 07:25 UTC (Revision 5).

@clawsweeper clawsweeper Bot added the merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. label Sep 26, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Oct 13, 2026
@obviyus

obviyus commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 14, 2026
@obviyus

obviyus commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 14, 2026
@obviyus

obviyus commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Maintainer override: the checks-fast-baseline-ratchets red on 111c4374a1 is inherited, not caused by this PR. This PR changes only Telegram inbound files.

The failing check is the mock-exports ratchet: src/process/terminal-pty.test.ts:40: ./terminal-pty-node.js ("First-party mock factories must preserve real exports or explain isolation"). Running the same check (scripts/check-test-mock-exports.mts) on clean origin/main 22841b2 fails with the identical line.

Failed job: https://github.com/openclaw/openclaw/actions/runs/38527685811/job/115732492613

All other product, type and test jobs pass, and the exact-head ClawSweeper review is ready.

@obviyus
obviyus merged commit addf193 into openclaw:main Oct 14, 2026
107 of 111 checks passed
@obviyus

obviyus commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Landed in addf193. Thanks @JamesY023! Verified on the Telegram Test Server: shared contacts now reach the agent and get a reply.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…144602)

fix(telegram): pass shared contact cards to the agent

A contact shared in Telegram had no text or media projection, so the message body was empty and the event was dropped: the bot never answered. Shared contacts now reach the agent with their name and phone number, and replies to a contact keep those details as quoted context. In mention-required groups a contact never counts as a mention, and real text mentions are still detected when they are forwarded together with a contact (in either order) or split across long-message fragments.

Proof: Telegram Test Server with a real user and a built Gateway, plus a real-provider turn. On main a shared contact produced no model request and no reply. With this change the contact details reach the model and the bot replies. The reply-to-contact, mention-required group, forwarded contact/text (both orders) and split-handle fragment controls behave correctly.

Thanks @JamesY023.

Co-authored-by: Ayaan Zaidi <[email protected]>
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. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S stale Marked as stale due to inactivity 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