Conversation
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In the non-streaming error branch, consider yielding a consistent value (e.g., an empty
MessageChainor the sameMessageChain().message(err_msg)) instead of a bareyieldso that downstream consumers don’t unexpectedly receiveNonewhile the streaming branch yields a message. - Add a short comment above the added
yieldexplaining that it’s required to trigger the pipeline scheduler and deliver the error result toRespondStage, so future refactoring doesn’t accidentally remove it.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In the non-streaming error branch, consider yielding a consistent value (e.g., an empty `MessageChain` or the same `MessageChain().message(err_msg)`) instead of a bare `yield` so that downstream consumers don’t unexpectedly receive `None` while the streaming branch yields a message.
- Add a short comment above the added `yield` explaining that it’s required to trigger the pipeline scheduler and deliver the error result to `RespondStage`, so future refactoring doesn’t accidentally remove it.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
There was a problem hiding this comment.
Pull request overview
Fixes a pipeline delivery gap where, in non-streaming agent runs, an LLM failure would set an error result on the event but never yield, so downstream stages (notably RespondStage) wouldn’t run and the error message could be silently dropped.
Changes:
- Add a missing
yieldafterastr_event.set_result(...)inrun_agent()’s non-streaming exception path so the scheduler can execute downstream stages and send the error to the user.
There was a problem hiding this comment.
Code Review
This pull request modifies the run_agent function in astrbot/core/astr_agent_run_util.py by adding a yield statement after setting the result on an event in the error handling path. This change ensures the asynchronous generator yields control back to the caller in this specific execution path. I have no feedback to provide.
|
测试了一整天现在写了自定义是不会漏报了 |
当人格配置了自定义报错文案后,用户侧的报错出口并没有被完整覆盖。
具体表现为:
run_agent()之前,例如build_main_agent()的前置处理、reset_coro、图片/引用图片解析等阶段时,异常会直接落入InternalAgentSubStage的外层except,用户仍然会看到原始内部错误,或者看到空前缀错误。run_agent()、ToolLoopAgentRunner、third_partyrunner 等不同路径的 fallback 文案也并不统一,有些路径仍会把底层异常文本直接暴露到消息平台。本次修改将用户侧错误出口统一为:
Modifications / 改动点
修改了以下核心文件:
astrbot/core/pipeline/process_stage/method/agent_sub_stages/internal.pyastrbot/core/astr_agent_run_util.pyastrbot/core/agent/runners/tool_loop_agent_runner.pyastrbot/core/pipeline/process_stage/method/agent_sub_stages/third_party.pyastrbot/core/persona_error_reply.py实现内容:
build_main_agent()之前,避免前置异常绕过已有的人格报错逻辑。persona_error_reply.py中新增统一的用户侧错误文案解析 helper,统一处理:InternalAgentSubStage外层异常run_agent()异常分支ToolLoopAgentRunner的llm_resp.role == "err"分支exc_info=True,保留排障信息但不再直接暴露给用户。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.
/ 我的更改没有引入恶意代码。