Skip to content

fix: queued follow-up replies omit automatic speech - #181592

Merged
obviyus merged 4 commits into
openclaw:mainfrom
indra622:fix/queued-followup-auto-tts-181557
Oct 23, 2026
Merged

obviyus merged 4 commits into
openclaw:mainfrom
indra622:fix/queued-followup-auto-tts-181557

Conversation

@indra622

@indra622 indra622 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Closes #181557

What Problem This Solves

With automatic audio enabled, an ordinary assistant turn receives speech, but a follow-up queued while that turn is running bypasses speech preparation and is delivered as plain text.

Changes

Prepare queued replies through the existing automatic-speech policy after destination selection and source suppression. Preserve session preferences, destination-account settings, prepared audio on routing fallback, cancellation/current authority checks, and the existing finalization lease. Stalled-recovery notices retain their existing delivery custody.

No configuration, plugin-SDK, or storage-contract change. Hosung Park (@indra622)'s fix and contributor commits are retained. The simplification removes a duplicate normal-versus-queued helper comparison; the stronger queued-delivery regression and distinct policy/lifecycle boundaries remain. Against the main merge base: production +74/-1, tests +375/-0 (24 fewer test lines than the adopted revision). The small speech module keeps this responsibility out of the already-large delivery module while reusing the existing policy and synthesis implementation.

Evidence

Built main e83e2c3bdf11cd5ad31eb6414c7072b72b3fdb32 and candidate f0350e945287fc6d2c115bb107864c71f77cfae7 on Node 24.22.1 in isolated Docker state. Configuration was created through shipped CLI commands. A normal Telegram ingress started the first turn; after the model stream began, public chat.send queued a follow-up in collect mode. Public session inspection confirmed an active run at admission. Both replies drained through the built Gateway and production delivery path.

Arm Speech requests Ordinary reply Queued reply
Main, run 1 1 voice text
Main, run 2 1 voice text
Candidate, run 1 2 voice voice
Candidate, run 2 2 voice voice
Main and candidate, audio disabled 0 each text text
Candidate, queued synthesis returns HTTP 503 2 attempts voice original text

The local OpenAI-compatible Responses/TTS fixtures record the exact requested text. The candidate's ordinary and queued multipart audio uploads match their respective distinct fixture bytes (5,925 and 5,980 bytes); both are Opus and fully decode with FFmpeg. Delivered captions/text match the corresponding model output.

Additional exact-head checks:

  • Real Telegram Test Server, Convex-leased user and bot: actual user ingress followed by public chat.send while the first stream was active. Two real sendVoice receipts, and TDLib 1.8.67 independently observed both replies as messageVoiceNote with the expected captions and sizes. Captured uploads fully decode. Run-owned messages were deleted and the lease released.
  • Real OpenAI gpt-5-mini through the shipped agent entry point returned QUEUED_SPEECH_LIVE_OK.
  • Two focused delivery suites: 97 tests passed. Targeted formatting and lint passed with zero warnings/errors.

Limits: the repeatable before/after runs use local model, TTS, and Telegram API fixtures. The additional real-Telegram run still uses the local model/TTS fixtures (valid synthetic tone audio, not spoken words); the real-provider gate is separate. No human speech-intelligibility claim is made.

Merge Danger

Two-way door: reverting restores the prior behavior without a migration. Blast radius is automatic speech for queued assistant replies; normal-turn speech and generic transport routing are unchanged.

@clawsweeper

clawsweeper Bot commented Oct 23, 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.

@indra622
indra622 marked this pull request as ready for review October 23, 2026 11:15
@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. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Applies the existing automatic speech policy to queued follow-up replies before delivery.

Example: With tts.auto set to always and Telegram collect mode enabled, a second message arrives during an active turn.

  • Before: The ordinary reply arrives as voice, but the queued reply arrives as text.
  • After: Both eligible replies arrive as voice, with text retained when synthesis fails.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused, worthwhile repair with shipped-entry-point evidence, distinct lifecycle regressions and no actionable finding; broad CI remains pending.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Exact-head Docker Gateway runs exercise Telegram ingress, busy-turn queue admission, synthesis, media persistence and upload, showing queued text on base versus queued voice on candidate, with disabled-speech and synthesis-failure controls; real Telegram Test Server receipts and TDLib observations supplement those runs, while real-model verification is separate and synthetic audio proves no speech intelligibility.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users who enable automatic speech receive text-only replies when messages queue behind an active turn.
Reason: Queued delivery should honor the same configured speech contract as ordinary assistant replies, and the patch restores that behavior with bounded scope.

Merge readiness

✅ Ready for maintainer review

This PR fixes a current queued-reply speech omission with a focused implementation and credible production-path evidence; no actionable defect was found.

Priority: P2
Reviewed head: f0350e945287fc6d2c115bb107864c71f77cfae7

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied Gateway runs cover the changed shipped path; a red-on-base run of the committed regression suite is not recorded.
Agent review details

How this fits together

The follow-up delivery owner receives completed queued reply payloads, selects their destination, applies source suppression and speech preparation, then routes or returns them to the source dispatcher.

flowchart TD
  A[Queued turn completes] --> B[Resolve reply payloads]
  B --> C[Select route and suppress]
  C --> D[Existing speech policy and synthesis]
  D --> E[Origin channel delivery]
  D --> F[Source dispatcher]
Loading

Technical review

Best possible solution:

Apply the existing speech policy once at queued delivery, preserving destination scope, source suppression, cancellation and text fallback.

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

Current-main source exposes the missing preparation step, and the supplied Gateway baseline reproduces ordinary voice followed by queued text; this read-only review ran no target code.

Is this the best way to solve the issue?

The patch restores the documented behavior through the existing speech owner without adding configuration, storage, transport policy or a competing synthesis implementation.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Queued delivery ownership keeps the original intent (f8cc39c: The merged convergence refactor made queued turns thin adapters into shared execution while retaining their final-delivery decisions.)
  • Collected-source reply suppression keeps the original intent (824e909: Queued passive Slack failures must share source-specific suppression without silencing explicit requests in a collected batch.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

PR surface

Source +73, Tests +375. Total +448 across 3 files. Added test files: 1.

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

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: Configured speech is omitted from queued replies while their text remains available, giving this fix a 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.

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 (3 earlier review cycles)
  • reviewed 2026-10-23T11:33:11.305Z sha b37509e :: needs real behavior proof before merge. :: [P2] Preserve exports or annotate the outbound mock separately
  • reviewed 2026-10-23T12:50:31.498Z sha 7f6dc29 :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-23T14:38:13.056Z sha 7f6dc29 :: needs maintainer review before merge. :: none

Reviewed October 23, 2026, 1:26 PM ET / 17:26 UTC (Revision 4).

@wr-web

wr-web commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Independent live-run evidence for #181557, in case it helps review. I had an equivalent local fix and am not opening a competing PR.

Setup: a real openclaw gateway run (Windows 11, Node 26.12.1) with the Telegram channel, tts.auto: "always" (OpenAI speech provider) and messages.queue.byChannel.telegram: "collect", against local stand-ins for the Bot API, an OpenAI-compatible model and /audio/speech.

live run

reply main e44fb5c with routed-follow-up TTS
DM #1 (normal turn) speech requested, sendVoice speech requested, sendVoice
DM #2 (queued follow-up) no speech request, sendMessage text speech requested, sendVoice

The second column comes from my equivalent change, which applies the existing reply TTS policy before routeReply in deliverFollowupDecision's origin route, not from this exact head. Treat it as corroboration of the expected behavior.

@indra622

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Updated the PR's Evidence section with a retained exact-head built-Gateway baseline/candidate comparison and the self-contained harness. The Gateway's normal Telegram ingress, busy-turn queue drain, speech synthesis, persistence, and HTTP upload now show baseline normal voice + queued text versus candidate normal voice + queued voice. The queued Ogg/Opus upload also passed an independent full decode. The previous mock-export finding is fixed in the current head and CI gates pass.

The model and Bot API endpoints are explicitly labeled local stand-ins; real-service/client delivery and human listening remain unverified. The description preserves those limits and all setup/cleanup failures. Please assess the new production-path evidence without treating the stand-ins as live Telegram proof.

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 23, 2026
@indra622

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added the missing exact-head real-model/channel-recipient evidence to the PR body for unchanged head 7f6dc297188350ba2fbb2114c818ce719dbff74e.

A real native Gemini model answered two human Telegram messages through the packaged Gateway. The second arrived while the first turn was busy, and production diagnostics confirm the follow-up barrier and mailbox selection. Both normal and queued replies were delivered through the actual Telegram Bot API as sendVoice (HTTP 200); both Ogg/Opus uploads fully decoded, and the human recipient confirmed both played clearly. The body includes redacted timestamps, audio properties/hashes, test adaptations, and cleanup results.

The first model response was deliberately held for 15 seconds; actual model request/response bodies were unchanged, and the task-local Telegram adapter forwarded to the real service. The live run validates the candidate only, not a live baseline comparison. Earlier failed connection attempts and out-of-scope channels are explicitly distinguished. No production configuration or source changes were made.

@clawsweeper

clawsweeper Bot commented Oct 23, 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: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Oct 23, 2026
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 23, 2026
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

The exact-head review is complete (5/6, no findings), but CI has one failing test job: checks-node-changed-compact-large-24.

src/auto-reply/reply/dispatch-from-config.delivery.test.ts reports 27 failures with Physical session already has a different controller owner. I ran that entire file with the repository-pinned Bun on this head and again with the changed follow-up delivery owner restored to main e83e2c3bdf11cd5ad31eb6414c7072b72b3fdb32: both runs have the identical 27 failing cases and 265 passing cases. For example, delivers provider conversation-state runner payloads as outbound channel replies fails identically in both arms.

The stack fails during bindSessionControllerEntryTarget → reply-operation admission → prepareDispatchOperation, before the queued-delivery speech preparation added here. The baseline replacement removes the import/call to the new speech module; the new queued-speech test is not part of these single-file runs. This is inherited admission/test-state failure, not a queued-speech regression. Cancelled jobs: 0. No CI jobs were rerun.

@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Maintainer override: the failing shard is an inherited failure, not caused by this PR.

27 cases in dispatch-from-config.delivery.test.ts fail with "Physical session already has a different controller owner": https://github.com/openclaw/openclaw/actions/runs/39994615892/job/120555537208. With the pinned Bun and the same test group, this head and the same tree with only this PR's production diff reverted to main give identical results: 27 failed, 265 passed. The failures happen before the queued-delivery code this PR changes. Evidence: #181592 (comment). All other required checks pass.

@obviyus
obviyus merged commit ec58b69 into openclaw:main Oct 23, 2026
129 of 132 checks passed
@obviyus

obviyus commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

Landed in ec58b69. Thanks @indra622. Queued follow-up replies now get automatic speech too.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 24, 2026
fix(tts): prepare automatic speech for queued follow-up replies

In conversations set to automatic audio, normal replies were turned into speech but queued follow-up replies skipped the speech preparation and arrived as plain text. Queued replies now go through the same automatic speech step. With audio off nothing changes, and a synthesis failure still falls back to text.

Evidence: built Gateway with a local OpenAI-compatible TTS/Responses fixture that records speech requests, auto audio set through shipped commands, a follow-up queued through public chat.send while a turn was running. On main there was one speech request and the queued reply was delivered as text (twice); with this change there are two speech requests and both replies are delivered as voice (twice). A real Telegram Test Server run recorded both voice replies. Production +74/-1.

Thanks @indra622.

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

P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. 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.

[Bug]: Auto-TTS (tts.auto: "always") is never applied to queued follow-up replies

3 participants