Skip to content

fix(respond): keep platform-specific components when checking for empty chains - #10716

Open
rudycelekli wants to merge 1 commit into
AstrBotDevs:masterfrom
rudycelekli:fix/respond-platform-specific-components
Open

rudycelekli wants to merge 1 commit into
AstrBotDevs:masterfrom
rudycelekli:fix/respond-platform-specific-components

Conversation

@rudycelekli

@rudycelekli rudycelekli commented Oct 23, 2026 •

Copy link
Copy Markdown

RespondStage._is_empty_message_chain only knows the built-in component types. Any component without an entry in _component_validators is treated as empty, so a chain made only of platform-specific components, such as DiscordEmbed or DiscordView, is dropped with The message is empty; skipping the respond stage. before it reaches the Discord adapter. #7965 describes this as the third part of the issue. The same thing happens to a chain that contains only AtAll, because it is a subclass of At and the lookup is by exact type.

The respond stage cannot know what makes a platform component empty, so it should leave that decision to the adapter.

Related to #7965. This complements #10710, which fixes constructing the Discord components; this PR is independent of it.

Modifications / 改动点

  • astrbot/core/pipeline/respond/stage.py: a component with no registered validator now counts as content. Built-in components keep their existing checks, so empty Plain, Image(file="") and similar chains are still skipped.

  • tests/unit/test_respond_stage_empty_chain.py: covers a platform-specific component on its own and next to blank text, and checks that empty built-in chains are still skipped.

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

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

$ uv run pytest tests/unit/test_respond_stage_empty_chain.py tests/unit/test_aiocqhttp_poke.py tests/unit/test_aiocqhttp_reply.py tests/test_slack_tts.py tests/test_qqofficial_group_message_create.py -q
61 passed

ruff format / ruff check pass.


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. / 我的更改经过了良好的测试,并已在上方提供了“验证步骤”和“运行截图”。
  • 📚 No WebUI navigation, page structure or labels changed, so no documentation update is needed. / 未改动 WebUI 入口、页面结构或术语,无需更新文档。
  • 🤓 I have ensured that no new dependencies are introduced. / 我确保没有引入新依赖库。

Summary by Sourcery

Allow platform-specific message components to reach adapters while retaining existing empty-chain filtering for built-in components.

Bug Fixes:

  • Preserve message chains containing platform-specific components so they can be handled by the appropriate adapter instead of being incorrectly skipped as empty.

Enhancements:

  • Continue applying existing emptiness checks to built-in components while treating unregistered component types as content.

Tests:

  • Add coverage for platform-specific components alongside blank text and verify that genuinely empty built-in chains remain skipped.

…ty chains

Co-authored-by: Cursor <cursoragent@cursor.com>

@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 assessment

Needs a human reviewer. Unknown platform-specific components now make a chain non-empty, so it can be passed on and sent through the platform adapter. If that causes an unintended response or card to reach users, reverting prevents future sends but cannot unsend what was already delivered.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant