Repository navigation
fix: queued follow-up replies omit automatic speech - #181592
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 changesApplies 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.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete 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 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe 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]
Technical reviewBest 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
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +73, Tests +375. Total +448 across 3 files. Added test files: 1. View PR surface stats
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 (3 earlier review cycles)
Reviewed October 23, 2026, 1:26 PM ET / 17:26 UTC (Revision 4). |
|
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
The second column comes from my equivalent change, which applies the existing reply TTS policy before |
|
@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. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review Added the missing exact-head real-model/channel-recipient evidence to the PR body for unchanged head 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 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. |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
The exact-head review is complete (5/6, no findings), but CI has one failing test job: checks-node-changed-compact-large-24.
The stack fails during |
|
Maintainer override: the failing shard is an inherited failure, not caused by this PR. 27 cases in |
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]>

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
e83e2c3bdf11cd5ad31eb6414c7072b72b3fdb32and candidatef0350e945287fc6d2c115bb107864c71f77cfae7on 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, publicchat.sendqueued 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.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:
chat.sendwhile the first stream was active. Two realsendVoicereceipts, and TDLib 1.8.67 independently observed both replies asmessageVoiceNotewith the expected captions and sizes. Captured uploads fully decode. Run-owned messages were deleted and the lease released.gpt-5-minithrough the shipped agent entry point returnedQUEUED_SPEECH_LIVE_OK.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.