fix(agent): bound per-session file state
This commit is contained in:
1 parent
ecef2b055d
commit
42afebb0cb
8 files changed
+73
-7
No files matched your search
@@ -76,6 +76,7 @@ from nanobot.session.goal_state import (
|
||||
from nanobot.session.history_visibility import HIDDEN_HISTORY_META
|
||||
from nanobot.session.keys import UNIFIED_SESSION_KEY, remember_last_channel
|
||||
from nanobot.session.manager import (
|
||||
SESSION_CACHE_MAX_SIZE,
|
||||
Session,
|
||||
SessionManager,
|
||||
replay_max_messages_for_context,
|
||||
@@ -380,7 +381,7 @@ class AgentLoop:
|
||||
self.tools = tool_registry if tool_registry is not None else ToolRegistry()
|
||||
# One file-read/write tracker per logical session. The tool registry is
|
||||
# shared by this loop, so tools resolve the active state via contextvars.
|
||||
self._file_state_store = FileStateStore()
|
||||
self._file_state_store = FileStateStore(max_sessions=SESSION_CACHE_MAX_SIZE)
|
||||
self._exec_session_manager = ExecSessionManager()
|
||||
self.runner = AgentRunner()
|
||||
self.subagents = SubagentManager(
|
||||
@@ -818,8 +819,13 @@ class AgentLoop:
|
||||
self.sessions.invalidate(key)
|
||||
await self._cancel_active_tasks(key)
|
||||
finally:
|
||||
self.discard_session_file_state(key)
|
||||
self._discarding_sessions.discard(key)
|
||||
|
||||
def discard_session_file_state(self, key: str) -> None:
|
||||
"""Forget ephemeral file-read state for a reset or removed session."""
|
||||
self._file_state_store.discard(key)
|
||||
|
||||
def _effective_session_key(self, msg: InboundMessage) -> str:
|
||||
"""Return the session key used for task routing and mid-turn injections."""
|
||||
if self._unified_session and not msg.session_key_override:
|
||||
|
||||
Reference in new issue
Block a user