When the LLM re-requests the same idempotent tool with identical args
(common during self-repair recovery, stuck job retries, or chat-mode
retry loops), the cache returns the previous result instantly without
re-executing.
Design improvements over the closed PR #204:
- Single global LRU cache (lru crate) instead of per-job HashMap with
O(N) manual eviction
- Global cap of 2000 entries prevents memory leaks from chat-path
ephemeral job IDs that never get invalidated
- TTL expiry (30min) checked on read; LRU eviction handles the rest
- Job invalidation still runs on worker completion for prompt cleanup
Idempotent tools: echo, time, json, memory_read/search/tree,
read_file, list_dir, list_jobs, job_status.
Closes#204
Co-Authored-By: Claude Opus 4.6 <[email protected]>