fix: check OnWaitingLLMRequestEvent stop signal before acquiring session lock#8935
fix: check OnWaitingLLMRequestEvent stop signal before acquiring session lock#8935Foolllll-J wants to merge 1 commit into
Conversation
|
@Foolllll-J is attempting to deploy a commit to the soulter's projects Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Code Review
This pull request updates the internal agent sub-stage processing logic to check the return value of the OnWaitingLLMRequestEvent event hook. If the hook returns a truthy value, the process returns early, preventing further execution and the acquisition of the session lock. There are no review comments, and I have no additional feedback to provide.
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.
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- Since
call_event_hookis now used as a gate to short-circuit the pipeline, consider making its return contract explicitly boolean (or explicitly checkingis True) and documenting thatTruemeans the request was stopped, to avoid accidental truthy values changing control flow. - It may be helpful to add a debug-level log right before the
returnwhenOnWaitingLLMRequestEventstops the pipeline so that it’s easier to trace why a particular LLM request never acquired the session lock.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Since `call_event_hook` is now used as a gate to short-circuit the pipeline, consider making its return contract explicitly boolean (or explicitly checking `is True`) and documenting that `True` means the request was stopped, to avoid accidental truthy values changing control flow.
- It may be helpful to add a debug-level log right before the `return` when `OnWaitingLLMRequestEvent` stops the pipeline so that it’s easier to trace why a particular LLM request never acquired the session lock.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
修复
OnWaitingLLMRequestEventhook 的返回值和event.is_stopped()未被检查的问题,导致插件在该 hook 中调用event.stop_event()后,pipeline 仍然继续获取会话锁并执行 LLM 请求。Modifications / 改动点
astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py:213— 将await call_event_hook(event, EventType.OnWaitingLLMRequestEvent)的返回值改为条件检查:如果 hook 返回True(事件被停止),直接return终止 pipeline,与同文件中OnLLMRequestEvent的处理方式保持一致。This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
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.txtandpyproject.toml./ 我确保没有引入新依赖库,或者引入了新依赖库的同时将其添加到
requirements.txt和pyproject.toml文件相应位置。😮 My changes do not introduce malicious code.
/ 我的更改没有引入恶意代码。
Summary by Sourcery
Bug Fixes: