From 1bc8175f695519e143f1a0364ff8535972a11ccc Mon Sep 17 00:00:00 2001 From: LIghtJUNction Date: Wed, 29 Apr 2026 04:26:42 +0800 Subject: [PATCH] fix: make registered_web_apis/_register_tasks instance vars, add reset_runtime_registrations Class-level list vars caused cross-instance sharing. Tests expecting isolated registration containers failed. Move to __init__ and add the reset_runtime_registrations helper that tests depend on. --- astrbot/core/star/context.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/astrbot/core/star/context.py b/astrbot/core/star/context.py index d140b9361..fc790c4f1 100644 --- a/astrbot/core/star/context.py +++ b/astrbot/core/star/context.py @@ -101,6 +101,9 @@ class Context: self.cron_manager = cron_manager """Cron job manager, initialized by core lifecycle.""" self.subagent_orchestrator = subagent_orchestrator + self.registered_web_apis: list = [] + self._register_tasks: list[Awaitable] = [] + self._star_manager = None async def llm_generate( self, @@ -704,6 +707,11 @@ class Context: ) star_handlers_registry.append(md) + def reset_runtime_registrations(self) -> None: + """Reset runtime registration containers (web APIs and tasks).""" + self.registered_web_apis.clear() + self._register_tasks.clear() + def register_task(self, task: Awaitable, desc: str) -> None: """[DEPRECATED]注册一个异步任务。