Skip to content

fix(gateway): invalidate Honcho memory cache on rapid rewrites - #59355

Closed
Kye-AI-Kye wants to merge 1 commit into
NousResearch:mainfrom
Kye-AI-Kye:pr/gateway-honcho-cache-invalidate
Closed

fix(gateway): invalidate Honcho memory cache on rapid rewrites#59355
Kye-AI-Kye wants to merge 1 commit into
NousResearch:mainfrom
Kye-AI-Kye:pr/gateway-honcho-cache-invalidate

Conversation

@Kye-AI-Kye

Copy link
Copy Markdown

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

Copilot AI review requested due to automatic review settings July 6, 2026 04:03

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread gateway/run.py
Comment on lines +15242 to +15244
_HONCHO_CACHE_BUSTING_MEMO: dict[
tuple[str, int | None, int | None], dict[str, Any]
] = {}
Comment thread gateway/run.py
Comment on lines +15258 to +15264
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)
@alt-glitch alt-glitch added type/bug Something isn't working P3 Low — cosmetic, nice to have comp/gateway Gateway runner, session dispatch, delivery tool/memory Memory tool and memory providers comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists labels Jul 6, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #46385 — both add st_size to the _HONCHO_CACHE_BUSTING_MEMO key in gateway/run.py so rapid honcho.json rewrites on coarse-mtime filesystems bust the memo (byte-equivalent mechanism; only variable names differ). #46385 is the earlier still-open canonical fix; #47844 was the same fix and is now closed.

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@Kye-AI-Kye

Copy link
Copy Markdown
Author

Closing as a duplicate of #46385, the earlier canonical fix adding st_size to the Honcho cache-busting key. Thanks!

@Kye-AI-Kye Kye-AI-Kye closed this Jul 6, 2026
@Kye-AI-Kye
Kye-AI-Kye deleted the pr/gateway-honcho-cache-invalidate branch July 6, 2026 04:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery comp/plugins Plugin system and bundled plugins duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants