fix: conversation was still saved to the context after stop_event
#4345
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.
Motivation / 动机
修复了在
OnLLMResponseEvent钩子中调用stop_event()后,本轮对话仍会被保存到上下文的问题。之前的行为:当插件在
OnLLMResponseEvent钩子中调用event.stop_event()时,虽然本次回复不会输出给用户,但对话历史(包括用户消息和 LLM 响应)仍然会被保存到会话上下文中,导致后续对话会包含这次被"停止"的对话内容。期望行为:调用
stop_event()后,本轮对话既不输出,也不保存到上下文。Modifications / 改动点
核心文件修改:*
astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.py_save_to_history()前增加event.is_stopped()检查This is NOT a breaking change. / 这不是一个破坏性变更。
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
requirements.txt和pyproject.toml文件相应位置。/ I have ensured that no new dependencies are introduced, OR if new dependencies are introduced, they have been added to the appropriate locations inrequirements.txtandpyproject.toml.Summary by Sourcery
错误修复:
Original summary in English
Summary by Sourcery
Bug Fixes: