From aab095347fca560de4dd304dc126906a15402b58 Mon Sep 17 00:00:00 2001 From: Li-shi-ling <114913764+Li-shi-ling@users.noreply.github.com> Date: Tue, 10 Feb 2026 11:01:49 +0800 Subject: [PATCH] fix: 'HandoffTool' object has no attribute 'agent' (#5005) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 移动agent的位置到super().__init__之后 * add: 添加一行注释 --- astrbot/core/agent/handoff.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/astrbot/core/agent/handoff.py b/astrbot/core/agent/handoff.py index 68bccb8f9..761c50269 100644 --- a/astrbot/core/agent/handoff.py +++ b/astrbot/core/agent/handoff.py @@ -15,7 +15,6 @@ class HandoffTool(FunctionTool, Generic[TContext]): tool_description: str | None = None, **kwargs, ) -> None: - self.agent = agent # Avoid passing duplicate `description` to the FunctionTool dataclass. # Some call sites (e.g. SubAgentOrchestrator) pass `description` via kwargs @@ -34,6 +33,8 @@ class HandoffTool(FunctionTool, Generic[TContext]): # Optional provider override for this subagent. When set, the handoff # execution will use this chat provider id instead of the global/default. self.provider_id: str | None = None + # Note: Must assign after super().__init__() to prevent parent class from overriding this attribute + self.agent = agent def default_parameters(self) -> dict: return {