fix(core): terminate active events on reset/new/del to prevent stale responses#5225
Merged
Soulter merged 2 commits intoAstrBotDevs:masterfrom Feb 19, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
嗨——我已经审查了你的修改,看起来非常棒!
帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈来改进后续的审查。
Original comment in English
Hey - I've reviewed your changes and they look great!
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Soulter
approved these changes
Feb 19, 2026
Raven95676
added a commit
to Raven95676/AstrBot_Rdev
that referenced
this pull request
Feb 20, 2026
- Integrate active_event_registry register/unregister into new PipelineExecutor to restore AstrBotDevs#5225 (terminate active events on reset/new/del) - Add missing component validators (Json, Share, Music, Forward, Location, Contact, Shake, Dice, RPS, Unknown) to SendService to restore AstrBotDevs#5208 (JSON-only message empty reply error) - Invoke OnPluginErrorEvent hook in CommandDispatcher error path to restore AstrBotDevs#5192 (plugin error hook for custom error routing) - Pass text=comp.text when creating TTS Record to restore AstrBotDevs#5204 (voice_messages_forbidden fallback caption on Telegram)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联 Issue
Ref #5222
改动文件
背景
用户在 LLM 请求(特别是工具调用)正在处理时执行
/reset、/new或/del,旧请求的响应仍然会被发送给用户,导致混乱和不一致的体验。根因
/reset、/new、/del命令在执行会话操作前,没有终止该会话下正在处理的活跃事件。事件的stop_event()/is_stopped()机制已存在,但缺少从会话命令到活跃事件的查找和终止能力。修复内容
1. 新增
ActiveEventRegistry(astrbot/core/utils/active_event_registry.py)unified_msg_origin→ 活跃事件集合的映射register()、unregister()、stop_all(umo, exclude=)方法session_lock.py的模式2. 修改
PipelineScheduler.execute()(astrbot/core/pipeline/scheduler.py)execute()入口处注册事件finally块中注销事件,确保无论正常完成还是异常退出都会清理3. 修改会话命令(
conversation.py)reset():在清除对话历史前,调用stop_all()终止该 UMO 下所有其他活跃事件new_conv():在创建新对话前,终止活跃事件del_conv():在删除对话前,终止活跃事件exclude=message排除自身,确保命令自身的响应正常发出行为变化
/reset、/new或/del,旧的 LLM 响应仍会在命令执行后发出is_stopped()后中断,旧响应不再发出风险与兼容性
ActiveEventRegistry是纯新增模块,不影响现有代码路径PipelineScheduler.execute()改动仅增加了try/finally包装,不改变原有执行逻辑stop_all()只作用于同一 UMO 下的其他事件,不影响其他会话验证
/reset,确认旧响应未被发出/reset、/del命令均能正确终止活跃事件