Skip to content

fix(telegram): normalize announce group targets - #81229

Merged
giodl73-repo merged 1 commit into
openclaw:mainfrom
giodl73-repo:user/giodl/fix-telegram-announce-group-target
May 16, 2026
Merged

giodl73-repo merged 1 commit into
openclaw:mainfrom
giodl73-repo:user/giodl/fix-telegram-announce-group-target

Conversation

@giodl73-repo

@giodl73-repo giodl73-repo commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add a Telegram-owned messaging.resolveSessionTarget implementation so session-derived group targets normalize before announce delivery.
  • Keep core sessions_send generic: Telegram handles group:<chatId> in the Telegram plugin instead of teaching shared code channel-specific syntax.
  • Update the session conversation coverage so Telegram session group ids resolve to numeric Telegram chat ids.

Fixes #81086.

Tests

  • pnpm test extensions/telegram/src/targets.test.ts extensions/telegram/src/send.test.ts extensions/telegram/src/session-conversation.test.ts src/agents/tools/sessions-send-helpers.test.ts -- --reporter=verbose
  • pnpm check:changed
  • git diff --check

Real behavior proof

Behavior addressed: Telegram session-derived group targets normalize to a Telegram-sendable numeric chat id instead of the generic group:<chatId> form that Telegram rejects.

Real environment tested: ClawCode live Azure VM (clawcode-vm) running the PR build from ~/worktrees/openclaw-81229, captured on commit e2db3d10785d before the latest rebase of the same patch. Telegram was enabled for the ClawCode supergroup. The gateway service was restarted from this PR worktree and confirmed active before the proof.

Exact steps or command run after this patch: Restarted the gateway from the PR worktree, sent a direct Telegram group message with node dist/index.js message send --channel telegram --target "telegram:group:<redacted-supergroup-id>" --json, then invoked the sessions_send tool against the raw telegram:group:<id> session key.

Evidence after fix: Direct target proof returned a Telegram-sendable numeric chat id:

{
  "action": "send",
  "channel": "telegram",
  "dryRun": false,
  "handledBy": "plugin",
  "payload": {
    "ok": true,
    "messageId": "15",
    "chatId": "<redacted-numeric-supergroup-id>"
  }
}

Gateway confirmation from the same direct-send run:

/usr/bin/node /home/azureuser/worktrees/openclaw-81229/dist/index.js gateway --port 18789
[ws] ⇄ res ✓ message.action 808ms channel=telegram

sessions_send group-session proof returned announce delivery for the raw Telegram group session key:

{
  "runId": "c7e5db65-cb89-4b21-b113-2f2b79bfdc7e",
  "status": "ok",
  "sessionKey": "telegram:group:<redacted-supergroup-id>",
  "delivery": {
    "status": "pending",
    "mode": "announce"
  }
}

Target session message tool call, redacted:

{
  "action": "send",
  "channel": "telegram",
  "target": "<redacted-numeric-supergroup-id>",
  "message": "Announcement: The proof for PR 81229 is now available. Check it out! marker: proof-81229-clean-announce-1778654546"
}

Telegram tool result:

{
  "ok": true,
  "messageId": "21",
  "chatId": "<redacted-numeric-supergroup-id>"
}

Gateway confirmation from the same sessions_send run:

[agent/embedded] embedded run tool start: runId=c7e5db65-cb89-4b21-b113-2f2b79bfdc7e tool=message
[ws] ⇄ res ✓ message.action 729ms channel=telegram
[agent/embedded] embedded run tool end: runId=c7e5db65-cb89-4b21-b113-2f2b79bfdc7e tool=message
[agent:nested] session=agent:coder:telegram:group:<redacted-supergroup-id> run=c7e5db65-cb89-4b21-b113-2f2b79bfdc7e channel=webchat Announcement: The proof for PR 81229 is now available. Check it out! marker: proof-81229-clean-announce-1778654546

Observed result after fix: The direct Telegram send and the reported sessions_send entrypoint both delivered to the real Telegram supergroup. Telegram returned ok: true and the expected numeric chat id, showing the session-derived group target was normalized before delivery.

What was not tested: I did not test unrelated Telegram DM targets, non-Telegram channels, or the mobile UI. The proof is scoped to the failing Telegram group announce path.

@openclaw-barnacle openclaw-barnacle Bot added channel: telegram Channel integration: telegram size: XS maintainer Maintainer-authored PR labels May 13, 2026
@clawsweeper

clawsweeper Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

Summary
The PR adds a Telegram messaging.resolveSessionTarget hook, wires it into the Telegram plugin, and updates focused session-target normalization coverage.

Reproducibility: yes. source-reproducible: current main can derive group:<chatId> for a Telegram group session key while the Telegram send path requires a numeric chat ID or lookup target. I did not run a live failing Telegram reproduction in this read-only review.

Real behavior proof
Sufficient (terminal): The PR body includes after-fix terminal output and gateway logs from a live Telegram group announce path showing successful delivery and a numeric chat ID.

Next step before merge
No repairable defect remains; the next action is protected-label maintainer review and landing.

Security
Cleared: The diff only changes Telegram target-normalization code and focused tests; it does not touch dependencies, CI, secrets, install, release, or package-resolution surfaces.

Review details

Best possible solution:

Land this Telegram-owned resolver after explicit maintainer review, then close #81086 as fixed by the merge.

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

Yes, source-reproducible: current main can derive group:<chatId> for a Telegram group session key while the Telegram send path requires a numeric chat ID or lookup target. I did not run a live failing Telegram reproduction in this read-only review.

Is this the best way to solve the issue?

Yes. The PR uses the existing ChannelMessagingAdapter.resolveSessionTarget seam and keeps channel-specific target normalization inside the Telegram plugin, matching the maintainer review direction.

Acceptance criteria:

  • node scripts/run-vitest.mjs extensions/telegram/src/targets.test.ts extensions/telegram/src/send.test.ts extensions/telegram/src/session-conversation.test.ts src/agents/tools/sessions-send-helpers.test.ts -- --reporter=verbose
  • node scripts/crabbox-wrapper.mjs run ... --shell -- "pnpm check:changed"
  • git diff --check

What I checked:

Likely related people:

  • Peter Steinberger: Current blame on resolveAnnounceTargetFromKey, the Telegram messaging adapter, the Telegram session-conversation helper, and Telegram target normalization points to recent main-branch work carrying this path forward. (role: recent area contributor; confidence: medium; commits: b5ba210fd5c6; files: src/agents/tools/sessions-send-helpers.ts, extensions/telegram/src/channel.ts, extensions/telegram/src/session-conversation.ts)
  • galiniliev: Provided the PR-specific review direction that Telegram should own this normalization while core remains generic, and requested real Telegram announce-delivery proof before marking ready. (role: reviewer; confidence: high; files: extensions/telegram/src/channel.ts, extensions/telegram/src/session-conversation.ts)

Remaining risk / open question:

  • The protected maintainer label means this PR still needs explicit maintainer handling before landing.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 16e5d6692dcc.

@clawsweeper clawsweeper Bot added the mantis: telegram-visible-proof Mantis should capture Telegram visible proof. label May 13, 2026
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

/review

@clawsweeper

clawsweeper Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@giodl73-repo
giodl73-repo marked this pull request as draft May 13, 2026 03:53
@giodl73-repo

giodl73-repo commented May 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Applying the maintainer-proof pass from Galin's review style: this PR needs true after-fix Telegram delivery proof, not only resolver/unit output. I converted it back to draft until we can attach a redacted group-send proof or get explicit maintainer guidance that resolver-level proof is enough for this change.

Re-review progress:

@galiniliev

Copy link
Copy Markdown
Contributor

Thanks for moving this back to draft. The code direction looks right: Telegram owns the session-target normalization, and keeping core generic is the correct boundary for this fix.

Before marking ready, please attach real after-fix Telegram delivery proof for the reported path, not only resolver/unit output. The proof should show sessions_send with delivery.mode: "announce" targeting a Telegram group session key, where the candidate delivers a message to the Telegram group instead of handing Telegram a group:<chatId> target.

Preferred proof path:

@openclaw-mantis telegram desktop proof

Please capture before/after Telegram-visible proof for PR #81229. Prove sessions_send with delivery.mode: "announce" to a Telegram group session key. Baseline should show the current failure from group:<chatId> / non-numeric recipient; candidate should show a delivered Telegram group message. Redact chat IDs, tokens, phone numbers, and private endpoints.

Once Mantis posts evidence, mark ready for review and ask @clawsweeper re-review.

@galiniliev galiniliev self-assigned this May 13, 2026
@galiniliev

Copy link
Copy Markdown
Contributor

@openclaw-mantis telegram desktop proof

Please capture before/after Telegram-visible proof for PR #81229. Prove sessions_send with delivery.mode: "announce" to a Telegram group session key. Baseline should show the current failure from group: / non-numeric recipient; candidate should show a delivered Telegram group message. Redact chat IDs, tokens, phone numbers, and private endpoints.

@giodl73-repo
giodl73-repo force-pushed the user/giodl/fix-telegram-announce-group-target branch 2 times, most recently from 52e70e7 to 6e28e92 Compare May 13, 2026 04:59
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Rebased on current origin/main, fixed the formatter drift from the rebase, and reran focused verification.\n\nChecks:\n- oxfmt --check changed files\n- node scripts/test-projects.mjs extensions/telegram/src/session-conversation.test.ts --reporter=verbose\n- node scripts/check-changed.mjs\n- git diff --check\n\nStill draft pending real behavior proof for the Telegram announce target flow.\n\n@clawsweeper re-review

@giodl73-repo
giodl73-repo force-pushed the user/giodl/fix-telegram-announce-group-target branch 2 times, most recently from 2cc024a to e2db3d1 Compare May 13, 2026 06:06
@giodl73-repo

giodl73-repo commented May 13, 2026 •

Copy link
Copy Markdown
Contributor Author

Updated the PR body with live ClawCode proof for the sessions_send Telegram group session path. The run targets a raw telegram:group:<id> session key, returns delivery.mode: "announce", and the target session sends to the Telegram group with Telegram returning ok: true and a numeric chat id.

@clawsweeper re-review

Re-review progress:

@clawsweeper

clawsweeper Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label May 13, 2026
@giodl73-repo
giodl73-repo force-pushed the user/giodl/fix-telegram-announce-group-target branch 3 times, most recently from 25e5707 to f6340c1 Compare May 13, 2026 13:24
@giodl73-repo

Copy link
Copy Markdown
Contributor Author

Rebased on current origin/main and reformatted the Real behavior proof section to use the exact structured fields required by real-behavior-proof-check.mjs. The proof content is still the same redacted live ClawCode Telegram group send / sessions_send evidence that ClawSweeper marked sufficient.

@clawsweeper re-review

@giodl73-repo
giodl73-repo force-pushed the user/giodl/fix-telegram-announce-group-target branch 2 times, most recently from 1035609 to cc949e9 Compare May 13, 2026 13:32
@clawsweeper

clawsweeper Bot commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@giodl73-repo
giodl73-repo force-pushed the user/giodl/fix-telegram-announce-group-target branch from cc949e9 to fd1b72c Compare May 14, 2026 13:57
@clawsweeper

clawsweeper Bot commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@openclaw openclaw deleted a comment from openclaw-mantis Bot May 18, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 24, 2026
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
galiniliev pushed a commit to galiniliev/openclaw that referenced this pull request May 25, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
sablehead pushed a commit to sablehead/openclaw that referenced this pull request Jun 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: telegram Channel integration: telegram maintainer Maintainer-authored PR mantis: telegram-visible-proof Mantis should capture Telegram visible proof. proof: sufficient ClawSweeper judged the real behavior proof convincing. size: XS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sessions_send announce delivery fails for Telegram groups: recipient must be a numeric chat ID

2 participants