Claude: replace module-level file read states with per-loop per-session state class. fixes #3571

This commit is contained in:
LZDQ
2026-05-01 19:15:07 +08:00
committed by Xubin Ren
parent 6891a7a4d4
commit 58ae2d5b7e
7 changed files with 214 additions and 108 deletions
+10 -6
View File
@@ -168,12 +168,16 @@ class SubagentManager:
tools = ToolRegistry()
allowed_dir = self.workspace if (self.restrict_to_workspace or self.exec_config.sandbox) else None
extra_read = [BUILTIN_SKILLS_DIR] if allowed_dir else None
tools.register(ReadFileTool(workspace=self.workspace, allowed_dir=allowed_dir, extra_allowed_dirs=extra_read))
tools.register(WriteFileTool(workspace=self.workspace, allowed_dir=allowed_dir))
tools.register(EditFileTool(workspace=self.workspace, allowed_dir=allowed_dir))
tools.register(ListDirTool(workspace=self.workspace, allowed_dir=allowed_dir))
tools.register(GlobTool(workspace=self.workspace, allowed_dir=allowed_dir))
tools.register(GrepTool(workspace=self.workspace, allowed_dir=allowed_dir))
# Subagent gets its own FileStates so its read-dedup cache is
# isolated from the parent loop's sessions (issue #3571).
from nanobot.agent.tools.file_state import FileStates
file_states = FileStates()
tools.register(ReadFileTool(workspace=self.workspace, allowed_dir=allowed_dir, extra_allowed_dirs=extra_read, file_states=file_states))
tools.register(WriteFileTool(workspace=self.workspace, allowed_dir=allowed_dir, file_states=file_states))
tools.register(EditFileTool(workspace=self.workspace, allowed_dir=allowed_dir, file_states=file_states))
tools.register(ListDirTool(workspace=self.workspace, allowed_dir=allowed_dir, file_states=file_states))
tools.register(GlobTool(workspace=self.workspace, allowed_dir=allowed_dir, file_states=file_states))
tools.register(GrepTool(workspace=self.workspace, allowed_dir=allowed_dir, file_states=file_states))
if self.exec_config.enable:
tools.register(ExecTool(
working_dir=str(self.workspace),