Skip to content

fix(telegram): voice mentions are ignored in groups when audio scope rules match on chat type - #163746

Merged
obviyus merged 4 commits into
openclaw:mainfrom
jewseppi:fix/telegram-audio-preflight-chat-type
Oct 14, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
jewseppi:fix/telegram-audio-preflight-chat-type

Conversation

@jewseppi

@jewseppi jewseppi commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes: a voice note mentioning the bot is ignored in a mention-required Telegram group when audio transcription is allowed by a chatType: "group" scope rule.

User Impact

User impact: operators can use chat-type-scoped transcription without losing voice mentions in groups. Direct-only audio rules still do not admit group voice notes. No configuration migration or default changes are required.

Why This Change Was Made

The preliminary transcription context omitted the chat type. Pass the existing group/direct classification to the media scope evaluator before checking the transcribed mention.

Thanks to @jewseppi for reporting and fixing this. The contributor's commits are retained; the revision only removes explanatory comments. No overlap with Pash/Sarah changes.

Evidence

Built Gateway, real Telegram Test Server, Convex-leased TDLib user, captionless OGG voice note saying “Open Claw, reply VOICE OK.” The group required a mention and used the open[ -]?claw mention pattern. OpenAI gpt-4o-mini-transcribe performed actual transcription through a host-side proxy; only the reply provider was scripted.

Audio scope in the positive case:

{"default":"deny","rules":[{"action":"allow","match":{"chatType":"group"}}]}

The negative control replaced group with direct. All four cases downloaded the real Telegram voice attachment successfully and observed the same QA user's live TDLib updates for 45 seconds after sending.

Built source Allowed chat type Transcription requests Reply-provider requests Observed bot reply
Base 55cdb94fc8ba group 0 0 none
Head 4150c00484e8 group 1, HTTP 200 3 VOICE OK
Base 55cdb94fc8ba direct 0 0 none
Head 4150c00484e8 direct 0 0 none

Redacted head transcription response: {"text":"Open claw, reply voice OK."}. The TDLib observer received the separate messageText reply VOICE OK after the captionless messageVoiceNote. Each final proof run deleted its own observed messages and released its lease.

Focused regression suite: node scripts/run-vitest.mjs extensions/telegram/src/bot-message-context.body.test.ts --maxWorkers=1 — 34 passed; 82.95 seconds wall time. Isolated oxfmt --check, oxlint, and build passed. Production delta: +1/-0; test delta: +2/-0 against the merge base. The existing group and direct preflight cases assert the scope input without adding another Gateway fixture.

Merge danger: two-way door; reverting removes the context field without persisted state or schema changes. Blast radius is Telegram audio preflight admission, including mention-required group voice notes and direct-chat audio scope evaluation.

…match chat type

The audio preflight context carried no ChatType, so a tools.media.audio.scope
rule that matches on chatType could never apply to it. With a default-deny scope
that allows direct chats, voice notes in a Telegram DM were refused.
@clawsweeper

clawsweeper Bot commented Oct 2, 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: XS labels Oct 2, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Oct 2, 2026
@clawsweeper

clawsweeper Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Pass the Telegram conversation type into early audio transcription so existing chat-type scope rules work before voice-mention detection.

Example: A mention-required Telegram group allows audio with default deny and a chatType group rule; a captionless voice note says “Open Claw, reply VOICE OK.”

  • Before: The missing chat type prevents transcription, so the spoken mention is ignored.
  • After: The bot transcribes the voice note and replies VOICE OK; a direct-only audio rule still blocks it.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A minimal root-cause repair with supplied shipped-entry-point positive and negative proof, no persisted-format change, and no actionable findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied exact-head proof exercises Telegram's inbound owner through a built Gateway, real Test Server voice attachment, and actual transcription provider: group scope yields VOICE OK, while direct-only scope yields zero transcription and reply-provider requests; this resolves the previous review's Test Server request.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An allowed group voice note mentioning the bot receives no response because early transcription cannot match its configured chat type.
Reason: The change restores documented behavior using an existing context field and preserves the direct-only denial control.

Merge readiness

✅ Ready for maintainer review

This PR fixes a concrete bug still present on current main, with no actionable code or security findings.

Priority: P2
Reviewed head: 4150c00484e82e730a816e95c877d9c9210a8089

Before merge

None.

Findings

None.

Agent review details

How this fits together

Telegram inbound processing supplies media and conversation facts to shared audio transcription, then uses the transcript to decide whether a group message mentions the bot.

flowchart TD
  A[Telegram voice note] --> B[Telegram admission]
  B --> C[Audio preflight context]
  C --> D[Shared media scope evaluator]
  D --> E[Transcription provider]
  E --> F[Mention detection]
  F --> G[Agent reply]
Loading

Technical review

Best possible solution:

Merge the focused context repair through the normal exact-head CI gates.

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

Current-main source deterministically omits the field required by group scope matching; the supplied base/head Test Server observations corroborate the failure without a new reviewer-run reproduction.

Is this the best way to solve the issue?

Supplying the existing classification at its producer fixes the cause without changing scope policy, defaults, routing, or admission guards.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Telegram audio-preflight context and admission keeps the original intent (c5bc4b6: Carry channel, account, destination, and thread facts for transcript-echo routing; the merged DM repair separately preserves group-specific guards.)
  • Existing group and DM admission regressions keeps the original intent (refactor(telegram): remove redundant test coverage #155040: Consolidate Telegram tests while retaining distinct authorization, voice routing, and admitted-input contracts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit c5bc4b6 adds extensions/telegram/src/bot-message-context.body.ts:225 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c5bc4b689264; files: extensions/telegram/src/bot-message-context.body.ts)

PR surface

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

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 1 2 0 +2
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 3 0 +3

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Voice mentions are silently ignored for Telegram groups using chat-type-scoped audio rules, with a narrow fix and limited 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. Group voice-mention admission changes observable Telegram replies; the supplied Test Server proof covers the changed behavior and direct-only control.

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 (6 earlier review cycles)
  • reviewed 2026-10-02T19:48:42.524Z sha 1665d8c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-03T05:01:53.435Z sha 1665d8c :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-04T21:45:10.077Z sha 1665d8c :: blocked before merge. :: none
  • reviewed 2026-10-09T04:59:34.912Z sha 0fcbaba :: needs changes before merge. :: none
  • reviewed 2026-10-09T06:16:39.706Z sha 0fcbaba :: needs changes before merge. :: none
  • reviewed 2026-10-09T16:06:46.407Z sha 0fcbaba :: needs changes before merge. :: none

Reviewed October 14, 2026, 1:59 AM ET / 05:59 UTC (Revision 7).

@jewseppi

jewseppi commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper proof telegram-bot-e2e-proof

@jewseppi

jewseppi commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

Supplemental local proof for PR #163746 on exact head 1665d8c4143bb887537e075d741a1e9978ce4be1.

This is not the requested Telegram Test Server proof yet; the live lane still requires either a maintainer-issued proof command or the QA Convex broker credential pair. It does prove the patched Telegram voice-preflight behavior in the focused regression suite on this PR head.

Command run locally from a fresh checkout of jewseppi:fix/telegram-audio-preflight-chat-type:

PATH=/home/joseph/.local/opt/node-v24.21.0-linux-x64/bin:$PATH \
  pnpm exec vitest run extensions/telegram/src/bot-message-context.body.test.ts \
  -t 'transcribes only an authorized voice sender|honors topic audio-preflight precedence|preserves named-account.*voice' \
  --reporter=verbose

Result:

Test Files  1 passed (1)
Tests  6 passed | 44 skipped (50)
Duration  80.59s

✓ transcribes only an authorized voice sender with forum echo routing and untrusted framing
✓ honors topic audio-preflight precedence (true, undefined)
✓ honors topic audio-preflight precedence (true, false)
✓ honors topic audio-preflight precedence (false, true)
✓ preserves named-account unthreaded DM voice echo routing without a group mention
✓ preserves named-account DM topic voice echo routing without a group mention

Relevant assertion in extensions/telegram/src/bot-message-context.body.test.ts verifies the DM voice-note transcription context now carries ChatType: "direct" alongside AccountId: "atlas" and the Telegram destination, which is the fact the audio scope matcher needs for direct-chat rules.

Live proof status:

  • @clawsweeper proof telegram-bot-e2e-proof was posted by jewseppi, but the hosted workflow did not run proof because the actor is not recognized as an OpenClaw maintainer by that command path.
  • Direct dispatch of mantis-telegram-bot-e2e-proof.yml from this account failed with HTTP 403: Must have admin rights to Repository.
  • Local Test Server doctor now has tooling and dependencies installed, but cannot acquire a lease because there is no authenticated Convex launcher and no OPENCLAW_QA_CONVEX_SITE_URL / OPENCLAW_QA_CONVEX_SECRET_CI broker pair available to this agent.

Remaining step for merge-clearing proof: run the Telegram Test Server proof lane from a maintainer context or provide the QA broker credential pair through a masked secret path, then attach the live DM-allowed/group-denied observations.

@jewseppi jewseppi changed the title fix(telegram): voice notes are not transcribed when audio scope rules match on chat type fix(telegram): voice mentions are ignored in groups when audio scope rules match on chat type Oct 3, 2026
@jewseppi

jewseppi commented Oct 3, 2026

Copy link
Copy Markdown
Contributor Author

The before/after proof for the group voice-mention case is now in the PR description (same build of this head, run with and without the ChatType line).

The re-review it triggered did not run: the ClawSweeper job failed with AgentInputScanError: Agent input scan refused: deadline (run 37099860437), and the review is now on hold. Could a maintainer comment @clawsweeper re-review when convenient? Thanks.

@jewseppi

jewseppi commented Oct 4, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 4, 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 4, 2026
@clawsweeper clawsweeper Bot added status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 9, 2026
@jewseppi

jewseppi commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jewseppi

jewseppi commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor Author

The latest review has no code findings and rates the proof sufficient (5/6). Its only open item is a Telegram Test Server run assigned to the team proof-lane owner, which needs the team-held QA credentials. Nothing is pending on my side despite the "waiting on author" label that appeared after I pressed Update branch.

I tried to produce that Test Server run myself with the repository's userbot driver (user-driver.py, testDc: true) and my own API app, registering a fresh test user with a 99966XYYYY number. Telegram's Test Server sends the code request (authenticationCodeTypeSms, length 5) but rejects the documented fixed code with PHONE_CODE_INVALID: tried X×5 and X×6 on test DCs 1, 2 and 3, with TDLib 1.8.67 and with Telethon. So a contributor can't create a Test Server user without the team's pre-authorized pool.

Could a maintainer run the Test Server lane for this scenario, or accept the existing real-Telegram proof in the description?

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 9, 2026
@jewseppi

jewseppi commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

@obviyus this one needs the Telegram Test Server lane you ran for #166567. ClawSweeper now rates it 5/6 with no findings; its single open item is that team-run step ("no additional contributor proof action").

To make it quick, the scenario is one group with requireMention: true, a messages.groupChat.mentionPatterns entry, and a captionless voice note that starts with that name:

  • allow: tools.media.audio.scope = { default: "deny", rules: [{ action: "allow", match: { chatType: "group" } }] } → the transcript reaches the agent
  • control: same with chatType: "direct" → no dispatch

One practical note: user-driver.py can send text and photos but not voice notes. I have a small local patch that adds send --voice <file.ogg> (inputMessageVoiceNote), kept out of this PR to leave the head unchanged. Happy to open it as a separate PR or paste it here if that helps.

@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 status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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-node-compact-small-2 red on 4150c00484 is inherited, not caused by this PR. This PR changes one line in the Telegram inbound preflight context.

The failing case is test/scripts/update-restart-module-outcome.test.ts > retains package backups after unverified post-swap module failures, with unexpected acquireWithWait / collectUpdateDoctorFailureFacts dependency calls. It fails identically on unrelated Telegram PR #144602:

Neither diff can reach the updater. The exact-head ClawSweeper review is ready with no findings.

@obviyus
obviyus merged commit fb73592 into openclaw:main Oct 14, 2026
100 of 103 checks passed
@obviyus

obviyus commented Oct 14, 2026

Copy link
Copy Markdown
Collaborator

Landed in fb73592. Thanks @jewseppi! Verified on the Telegram Test Server: voice-note mentions in groups now follow the audio transcription scope.

vincentkoc added a commit that referenced this pull request Oct 14, 2026
* commit '98116a50c5e3191283f12ee210aa774273f2b8fc': (4815 commits)
  chore(ui): refresh control ui locales (#171839)
  fix(gateway): server tests time out when a parallel shard starts cold (#171289)
  fix(agentsapi): allow shared compaction tuning in hosted sessions (#171813)
  test(live): prepare runtime config for admitted fixtures
  test(update): stub state-read retry in restart module fixture
  fix(test): pnpm test fails on small cloud containers (#171732)
  fix(code-mode): recover safely from invalid wait IDs (#128886)
  test(update): load acquisition owner in restart regression
  perf(gateway): avoid full row warmup for project and catalog pickers (#171714)
  fix(telegram): voice mentions are ignored in groups when audio scope rules match on chat type (#163746)
  fix(workboard): only promote todo cards to ready (#171743)
  perf(sqlite): avoid repeated admission registry publication (#171788)
  perf: skip unused size accounting for sole session actors (#171777)
  improve(ollama): cover literal fenced command replies (#166561)
  refactor(talk): admit cross-store voice writes once (#171721)
  fix(gateway): recover a Gateway stuck in startup instead of blocking every start (#171678)
  fix(muse): offer Muse Code sign-in from Provider Access (#171790)
  perf: avoid full device lists during silent pairing (#171703)
  docs(cloud): one coherent zero-setup cloud environments guide (#171767)
  fix(test): include cloud move in sidebar action inventory
  ...
vincentkoc added a commit that referenced this pull request Oct 14, 2026
* commit '98116a50c5e3191283f12ee210aa774273f2b8fc': (185 commits)
  chore(ui): refresh control ui locales (#171839)
  fix(gateway): server tests time out when a parallel shard starts cold (#171289)
  fix(agentsapi): allow shared compaction tuning in hosted sessions (#171813)
  test(live): prepare runtime config for admitted fixtures
  test(update): stub state-read retry in restart module fixture
  fix(test): pnpm test fails on small cloud containers (#171732)
  fix(code-mode): recover safely from invalid wait IDs (#128886)
  test(update): load acquisition owner in restart regression
  perf(gateway): avoid full row warmup for project and catalog pickers (#171714)
  fix(telegram): voice mentions are ignored in groups when audio scope rules match on chat type (#163746)
  fix(workboard): only promote todo cards to ready (#171743)
  perf(sqlite): avoid repeated admission registry publication (#171788)
  perf: skip unused size accounting for sole session actors (#171777)
  improve(ollama): cover literal fenced command replies (#166561)
  refactor(talk): admit cross-store voice writes once (#171721)
  fix(gateway): recover a Gateway stuck in startup instead of blocking every start (#171678)
  fix(muse): offer Muse Code sign-in from Provider Access (#171790)
  perf: avoid full device lists during silent pairing (#171703)
  docs(cloud): one coherent zero-setup cloud environments guide (#171767)
  fix(test): include cloud move in sidebar action inventory
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…rules match on chat type (openclaw#163746)

fix(telegram): let group voice-note mentions honor the audio transcription scope

In a mention-required Telegram group, a voice note that spoke the bot's name was ignored even when the audio transcription scope allowed group chats. The preflight that transcribes voice notes to check for mentions did not pass the chat type, so a `chatType: group` scope rule never matched. The preflight context now includes the chat type.

Proof: Telegram Test Server with a real user and a built Gateway, a mention-required group, and audio scope `default: deny` with an allow rule for `chatType: group`. A captionless voice note saying the bot's name was ignored on main. With this change it is transcribed (OpenAI) and the bot replies "VOICE OK". With a direct-only scope, group voice notes are still ignored on both versions.

Thanks @jewseppi.

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: XS 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