mirror of
https://github.com/agentscope-ai/ReMe.git
synced 2026-11-05 07:39:47 +00:00
* refactor: share backend search, file responses, and vector digests * refactor(studio): remove unused scaffolding and share workspace updates * test: simplify async tests and share deterministic store fixtures
23 lines
783 B
Python
23 lines
783 B
Python
"""Shared access to application-lifetime tool context state."""
|
|
|
|
from typing import TYPE_CHECKING, Any, Final
|
|
|
|
if TYPE_CHECKING:
|
|
from ...components import ApplicationContext
|
|
|
|
|
|
class _ToolContextMixin:
|
|
"""Share storage access while leaving each step's state format independent."""
|
|
|
|
TOOL_CONTEXTS_KEY: Final[str] = "tool_contexts"
|
|
|
|
if TYPE_CHECKING:
|
|
app_context: "ApplicationContext | None"
|
|
kwargs: dict[str, Any]
|
|
|
|
def _tool_context_store(self, tool_context_id: str) -> dict:
|
|
if self.app_context is not None:
|
|
contexts = self.app_context.metadata.setdefault(self.TOOL_CONTEXTS_KEY, {})
|
|
else:
|
|
contexts = self.kwargs.setdefault(self.TOOL_CONTEXTS_KEY, {})
|
|
return contexts.setdefault(tool_context_id, {})
|