-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
fix: 'HandoffTool' object has no attribute 'agent' #5005
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: 'HandoffTool' object has no attribute 'agent' #5005
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey - 我在这里给出了一些总体反馈:
- 建议在
self.agent = agent附近加一条简短注释,说明这行代码必须放在super().__init__()之后赋值,因为父类的初始化方法会覆盖属性,这样可以避免以后重构时无意中再次引入这个 bug。
给 AI Agent 的提示
请根据本次代码审查中的评论进行修改:
## 总体评论
- 建议在 `self.agent = agent` 附近加一条简短注释,说明这行代码必须放在 `super().__init__()` 之后赋值,因为父类的初始化方法会覆盖属性,这样可以避免以后重构时无意中再次引入这个 bug。帮我变得更有用!请对每条评论点 👍 或 👎,我会根据你的反馈来改进后续的代码审查。
Original comment in English
Hey - I've left some high level feedback:
- Consider adding a short comment near
self.agent = agentexplaining that it must be assigned aftersuper().__init__()because the parent initializer overwrites attributes, so future refactors don’t accidentally reintroduce the bug.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Consider adding a short comment near `self.agent = agent` explaining that it must be assigned after `super().__init__()` because the parent initializer overwrites attributes, so future refactors don’t accidentally reintroduce the bug.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
|
这个bug藏的好深!我前半段时间一直以为是其他部位有什么操作将agent给去掉了 |
Dt8333
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
合并前可能需要重新跑一下action确认无问题。
在调用 HandoffTool 工具时,出现了 "HandoffTool 对象没有 'agent' 属性" 的错误。经过排查发现,问题出现在 HandoffTool 的 init 方法中。在 self.agent = agent 赋值之后,调用 super().init() 会导致 self.agent 属性被意外覆盖或删除。
Fixes #5004
Modifications / 改动点
改变了astrbot.core.agent.handoff文件
将self.agent = agent移动到super().__init__之后
Screenshots or Test Results / 运行截图或测试结果
Checklist / 检查清单
没有新功能
验证步骤在iss里面,运行截图在上方
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
错误修复:
HandoffTool在基类初始化之后仍然保留其agent属性,以避免出现“object has no attribute agent”(对象没有 agent 属性)的错误。Original summary in English
Summary by Sourcery
Bug Fixes:
Original summary in English
Summary by Sourcery
错误修复:
HandoffTool在基类初始化之后仍然保留其agent属性,以避免出现“object has no attribute agent”(对象没有 agent 属性)的错误。Original summary in English
Summary by Sourcery
Bug Fixes: