feat: add tool-level file cache with LRU eviction and mtime invalidation
Introduces FileCache (OrderedDict LRU, st_mtime_ns validation) to avoid redundant disk reads and duplicate content in conversation context. Read tools return a short "[Cached]" message on cache hit instead of resending unchanged file content, saving tokens. Write/edit/delete tools invalidate affected paths; str_replace pre-warms the cache after edits. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -97,11 +97,20 @@ class SneakyCodeApp(App):
|
||||
self._config.skills, self._config.agent.workspace_root
|
||||
)
|
||||
|
||||
# Create file cache if enabled
|
||||
self._file_cache = None
|
||||
fs_cache_cfg = self._config.tools.filesystem.cache
|
||||
if fs_cache_cfg.enabled:
|
||||
from app.utils.file_cache import FileCache
|
||||
|
||||
self._file_cache = FileCache(max_entries=fs_cache_cfg.max_entries)
|
||||
|
||||
# Create tool registry (SkillRunner wired after registry exists)
|
||||
self._tool_registry = create_default_registry(
|
||||
self._config.agent.workspace_root,
|
||||
self._config,
|
||||
skills_manager=self._skills_manager,
|
||||
file_cache=self._file_cache,
|
||||
)
|
||||
|
||||
# Create SkillRunner and late-bind it to skill tools
|
||||
|
||||
Reference in New Issue
Block a user