Skip to content

fix: add LRU eviction and expired-entry cleanup to web_fetch cache#71

Open
kumarabhirup wants to merge 2 commits into
mainfrom
fix/17-web-fetch-cache-eviction
Open

fix: add LRU eviction and expired-entry cleanup to web_fetch cache#71
kumarabhirup wants to merge 2 commits into
mainfrom
fix/17-web-fetch-cache-eviction

Conversation

@kumarabhirup
Copy link
Copy Markdown
Collaborator

Fixes #17

The web_fetch/web_search shared cache already had a max-size cap (100 entries) with FIFO eviction, but lacked true LRU semantics and expired-entry cleanup.

Changes to src/agents/tools/web-shared.ts:

  • LRU promotion on read: readCache() now re-inserts the entry at the end of the Map on hit, so frequently accessed entries survive eviction.
  • LRU promotion on write: writeCache() deletes-then-sets existing keys to maintain correct eviction order.
  • Expired-entry sweep on eviction: When the cache is full, expired entries are purged before falling back to LRU eviction of the oldest live entry.
  • Minor: Collapsed two Date.now() calls into one in writeCache.

Remove the hardcoded 'change-me' token value and leave
OPENCLAW_GATEWAY_TOKEN empty so users are forced to set it.
Added a clear comment with the openssl generation command and
a note that Docker/Podman setup scripts auto-generate it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

web_fetch cache uses unbounded Map with no eviction

1 participant