Prompt File Cache
Caches agent.read_prompt calls within a monologue to eliminate redundant disk I/O and template parsing.
README
Prompt File Cache
Caches agent.read_prompt calls within a monologue to eliminate redundant disk I/O and template parsing for frequently-referenced prompt files.
How it works
The plugin installs two @extensible hooks around Agent.read_prompt:
start/_10_cache.py— on every call, builds a stable cache key from the agent profile, project, file path, and kwargs. If a cached value exists for that key, it is returned and the original function is skipped.end/_10_cache.py— on a cache miss, the rendered prompt is written back to the cache for the next read.
The cache key filters out internal kwargs (_directories, _agent, _encoding, _source_file, _source_dir) so callers and internal callers share a single entry. Complex kwargs (dicts, lists) are JSON-serialized with sorted keys for stable hashing.
Cache area
Stored in the framework's in-memory cache under the area name prompt_file_cache(plugins). The (plugins) scope suffix puts this area inside the existing *(plugins)* glob that the framework clears when plugins are toggled, so toggling any plugin invalidates the cache automatically — no manual monologue_start clearing hook is needed.
When the cache helps
- Repeated reads of the same prompt file in a single monologue (e.g., each turn re-reads
agent.system.main.md). - Agents that handle many rapid turns without prompt-file changes.
- Any flow where
read_promptis dominated by disk I/O and template parsing rather than content changes.
When the cache does not help
- First read of a prompt (always a miss).
- Workloads where prompt content changes frequently across calls.
Notes
- The cache is process-local and in-memory; it is cleared on every Agent Zero restart.
- Entries are evicted automatically by the
job_loopafter 5 minutes of inactivity. - This plugin has no settings UI; the manifest declares empty
settings_sections.