Skip to content

fix: continue pipeline after TTS fallback#9166

Open
sjh9714 wants to merge 2 commits into
AstrBotDevs:masterfrom
sjh9714:fix/9131-tts-fallback-yield
Open

fix: continue pipeline after TTS fallback#9166
sjh9714 wants to merge 2 commits into
AstrBotDevs:masterfrom
sjh9714:fix/9131-tts-fallback-yield

Conversation

@sjh9714

@sjh9714 sjh9714 commented Jul 6, 2026

Copy link
Copy Markdown

Modifications / 改动点

Fixes #9131.

ResultDecorateStage.process() is an async generator, and the scheduler only continues to the following stages when the generator yields. When TTS failed, the fallback text was left in result.chain, but the stage completed without yielding, so RespondStage was not reached.

  • Yield once after normal result decoration completes so the response stage can send the fallback text.
  • Add regression coverage for a TTS provider failure preserving the text fallback and yielding control to the scheduler.

This keeps the existing early returns for empty results, streaming results, stopped events, and t2i failures unchanged.

  • This is NOT a breaking change. / 这不是一个破坏性变更。

Screenshots or Test Results / 运行截图或测试结果

  • .venv/bin/pytest tests/test_qqofficial_group_message_create.py::test_result_decorate_yields_after_tts_fallback -q (failed before the fix with assert 0 == 1, passed after the fix)
  • .venv/bin/pytest tests/test_qqofficial_group_message_create.py::test_result_decorate_segments_qqofficial_ws_plain_result tests/test_qqofficial_group_message_create.py::test_result_decorate_yields_after_tts_fallback -q
  • .venv/bin/pytest tests/test_qqofficial_group_message_create.py -q
  • .venv/bin/ruff check astrbot/core/pipeline/result_decorate/stage.py tests/test_qqofficial_group_message_create.py
  • .venv/bin/ruff format --check astrbot/core/pipeline/result_decorate/stage.py tests/test_qqofficial_group_message_create.py
  • git diff --check

Note: I used Codex while preparing this change, reviewed the final diff, and ran the listed checks locally.


Checklist / 检查清单

  • 😊 If there are new features added in the PR, I have discussed it with the authors through issues/emails, etc.
    / 如果 PR 中有新加入的功能,已经通过 Issue / 邮件等方式和作者讨论过。

  • 👀 My changes have been well-tested, and "Verification Steps" and "Screenshots" have been provided above.
    / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”

  • 🤓 I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations in requirements.txt and pyproject.toml.
    / 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到 requirements.txtpyproject.toml 文件相应位置。

  • 😮 My changes do not introduce malicious code.
    / 我的更改没有引入恶意代码。

Summary by Sourcery

Ensure the result decoration stage always yields once after decorating non-empty results so downstream response handling continues, even when TTS falls back.

Bug Fixes:

  • Fix pipeline stalls where RespondStage was not reached after a TTS provider failure, ensuring fallback text in the result chain is sent.

Tests:

  • Add regression test asserting ResultDecorateStage yields once and preserves fallback text when TTS audio generation fails.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. area:core The bug / feature is about astrbot's core, backend labels Jul 6, 2026

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request adds a yield statement at the end of the process method in ResultDecorateStage to ensure the fallback result is yielded after a TTS failure, and introduces a corresponding unit test to verify this behavior. The reviewer pointed out that a similar issue remains in the Text-to-Image (T2I) fallback path, where an early return in the exception handler prevents the execution from reaching the newly added yield statement.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread astrbot/core/pipeline/result_decorate/stage.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core The bug / feature is about astrbot's core, backend size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] TTS 失败后日志显示“使用文本发送”,但文本兜底没有实际发出

1 participant