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.
This commit is contained in:
LIghtJUNction
2026-04-29 04:26:42 +08:00
parent d6c4c70369
commit 1bc8175f69

View File

@@ -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]注册一个异步任务。