Repository navigation
fix(telegram): preserve shared contact details in messages - #144602
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesPreserves 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherTelegram 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +27, Tests +132. Total +159 across 4 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (4 earlier review cycles)
Reviewed October 14, 2026, 3:25 AM ET / 07:25 UTC (Revision 5). |
|
This pull request has been automatically marked as stale due to inactivity. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Maintainer override: the The failing check is the mock-exports ratchet: All other product, type and test jobs pass, and the exact-head ClawSweeper review is ready. |
|
Landed in addf193. Thanks @JamesY023! Verified on the Telegram Test Server: shared contacts now reach the agent and get a reply. |
…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]>
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 on3fb2048c2d4d25fdc411385ac9fb336dded6b5b9and 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 of111c4374a1aa, with no subsequent production change or contributor merge.Real Telegram Test Server proof used a Convex-leased TDLib user and built Gateway. Native
inputMessageContactcontained synthetic nameContactProbe Q7and phone+15550100001; the recorder observedmessageContact.55cdb94fc8ba3fb2048c2d4d[Shared contact] ContactProbe Q7, +15550100001; Telegram reply at 5.897 s[Replying to: "[Shared contact] ContactProbe Q7, +15550100001"]; reply at 16.887 sThe 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 ID94923390976; 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_infoon all eight forwarded messages. Source fixtures were deleted afterward. The contact name was@<leased-bot-username>in every pair.@bottext@bottext, then bot-name contactThere 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, thenclaw_bot help, with no mention entities. It fails on3fb2048c2d4d(zero admitted turns) and passes on111c4374a1aa(one turn with byte-for-byte assembled input). Both forwarded-contact order regressions also pass on111c4374a1aa.A focused real Test Server control on
111c4374a1aasent 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 OpenAIgpt-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):The focused
111c4374a1aasplit-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. On111c4374a1aa, 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.