Skip to content

fix: respect session plugin filters in cron agents - #10163

Merged
Soulter merged 3 commits into
AstrBotDevs:masterfrom
wcqqq1214:fix/10161-cron-plugin-filter
Sep 21, 2026
Merged

Soulter merged 3 commits into
AstrBotDevs:masterfrom
wcqqq1214:fix/10161-cron-plugin-filter

Conversation

@wcqqq1214

@wcqqq1214 wcqqq1214 commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

Fixes #10161. Cron agents skipped session plugin filtering, allowing disabled plugins to run hooks and expose LLM tools.

Modifications / 改动点

Initialize CronMessageEvent.plugins_name from the session's plugin_set, matching normal message handling. Add regression tests for whitelist, empty, wildcard, and default configurations.

Documentation: this backend-only fix does not change WebUI navigation, page structure, or labels. No updates to docs/zh, docs/en, or screenshots are needed, and no entry-point mapping or related changelog update applies.

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

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

pytest tests/unit/test_cron_manager.py tests/unit/test_cron_context_compression.py tests/unit/test_astr_main_agent.py -q
# 202 passed; the two restrictive-config regression cases failed before the fix.
ruff format .
ruff check .
# Passed

Verified with the actual astrbot_plugin_nobrowser_markdown_to_pic v1.6.1 in llm mode: an excluded plugin generated an image before the fix, but neither ran its hook nor exposed its tool afterward. Explicitly enabling it still produced an image. Used fixed model output and captured delivery locally; no live QQ test.

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 checked the affected WebUI instructions and screenshots in docs/zh and docs/en against the changed navigation, page structure, and labels, and updated them in this PR (or explained why no documentation update is needed). For renamed, moved, or merged entry points, I included an old entry → new entry mapping in the documentation and changelog.
    / 我已对照变化后的 WebUI 入口、页面结构和术语,核对并在本 PR 中更新 docs/zhdocs/en 的相关操作说明与截图(或说明无需更新文档的原因)。入口改名、移动或合并时,已在文档和 changelog 中补充 旧入口 → 新入口 对照。

  • 🤓 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

Respect session plugin policies when executing cron agents.

Bug Fixes:

  • Apply session plugin filtering to cron agent hooks and LLM tools so disabled plugins no longer execute or become available during scheduled runs.

Tests:

  • Add regression coverage for whitelist, empty, wildcard, and default session plugin configurations.

@wcqqq1214
wcqqq1214 marked this pull request as ready for review September 20, 2026 18:12

@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. If the session plugin policy is applied incorrectly, cron agents could invoke plugins or response hooks that the session disabled, potentially triggering unintended external actions. Reverting prevents future misfiltered runs, but any actions already performed by an incorrectly enabled plugin cannot be undone.


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

@Soulter
Soulter merged commit 8b5e24b into AstrBotDevs:master Sep 21, 2026
23 checks passed
@wcqqq1214
wcqqq1214 deleted the fix/10161-cron-plugin-filter branch September 21, 2026 08:46
BegoniaHe added a commit to Xero-Team/AstrBot that referenced this pull request Sep 21, 2026
Apply the session plugin_set filter to the fork-only background-wake
event in astr_agent_tool_exec.py and the BTW work event in
btw/submission.py, matching the cron agent fix from AstrBotDevs#10163. Without it,
background and BTW agent runs could invoke plugin hooks and tools that
the session config had excluded.

Related: AstrBotDevs#10163
Tested: uv run pytest --test-profile blocking -q
AI-Generated: true
Generated-At: 2026-09-21T17:45:06Z
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.

[Bug] 定时任务(cron)触发的 agent 运行绕过「按配置文件启用插件」(plugin_set)过滤

2 participants