fix(gateway): invalidate Honcho memory cache on rapid rewrites - #59355
fix(gateway): invalidate Honcho memory cache on rapid rewrites#59355Kye-AI-Kye wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the gateway’s agent-cache “cache busting” inputs for the Honcho memory provider by changing how Honcho’s honcho.json identity mapping is memoized, aiming to avoid stale reads after rapid config rewrites.
Changes:
- Expands the Honcho config memoization key from
(path, mtime_ns)to include additional file state (st_size). - Updates the docstring to describe memoization by file state rather than only mtime.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| _HONCHO_CACHE_BUSTING_MEMO: dict[ | ||
| tuple[str, int | None, int | None], dict[str, Any] | ||
| ] = {} |
| stat = path.stat() | ||
| mtime_ns = stat.st_mtime_ns | ||
| size = stat.st_size | ||
| except OSError: | ||
| mtime_ns = None | ||
| memo_key = (str(path), mtime_ns) | ||
| size = None | ||
| memo_key = (str(path), mtime_ns, size) |
Duplicate of #46385 — both add |
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
Changes
Fixes Honcho memory cache serving stale content on rapid rewrites by expanding the memoization key from (path, mtime_ns) to include st_size.
Quality
- Targeted fix for a race condition
- No security concerns
Reviewed by Hermes Agent
|
Closing as a duplicate of #46385, the earlier canonical fix adding st_size to the Honcho cache-busting key. Thanks! |
On rapid successive rewrites the Honcho memory cache could serve stale content because the cache was not invalidated when the underlying entry changed within the same window. This invalidates the cache on rewrite so subsequent reads reflect the latest state.
🤖 Generated with Claude Code