fix(honcho): bust gateway agent cache on session-prefix flips
Address review feedback on #39130: the new sessionAiPeerPrefix setting affects the resolved Honcho session key, which HonchoMemoryProvider freezes at construction (self._session_key). Because it wasn't part of the gateway's cached-agent signature, a live config flip left an existing gateway session bound to its old, AI-peer-agnostic Honcho session until an unrelated eviction or restart. Add honcho.session_ai_peer_prefix to _HONCHO_CACHE_BUSTING_KEYS and the _extract_honcho_cache_busting_config values so a flip rebuilds the cached agent on the next turn, mirroring the existing aiPeer / pin_peer_name / runtime_peer_prefix contracts. Also close the symmetric gap for the pre-existing user-side sessionPeerPrefix: it feeds the same resolve_session_name output (per-session/title/per-repo/ per-directory strategies) into the same frozen _session_key, so it had the identical live-flip staleness bug and was likewise absent from the cache signature. Fixing both keeps the two prefixes consistent. Add one config-flip regression test covering both keys, alongside the existing Honcho cache-signature test.
This commit is contained in:
@@ -703,7 +703,7 @@ class HonchoMemoryProvider(DialecticMixin, MemoryProvider):
|
||||
"pin_user_identity": bool(cfg.pin_peer_name),
|
||||
"runtime_identity_prefix": cfg.runtime_peer_prefix or "",
|
||||
"user_identity_aliases": sorted(aliases.items()),
|
||||
"session_prefixing": [bool(cfg.session_peer_prefix)],
|
||||
"session_prefixing": [bool(cfg.session_peer_prefix), bool(cfg.session_ai_peer_prefix)],
|
||||
"a2a_sessions": bool(cfg.a2a_sessions),
|
||||
}
|
||||
self._identity_signature_memo = {memo_key: values}
|
||||
|
||||
@@ -551,6 +551,23 @@ class TestPinTransition:
|
||||
assert sig_unpinned["memory.pin_user_identity"] is False
|
||||
assert not any(k.startswith("honcho.") for k in sig_pinned)
|
||||
|
||||
def test_identity_signature_reflects_both_session_prefixes(self, tmp_path, monkeypatch):
|
||||
"""Flipping either session prefix mid-flight must invalidate the cached agent: both feed the
|
||||
``resolve_session_name`` output frozen into the provider's ``_session_key`` at construction."""
|
||||
from plugins.memory.honcho import HonchoMemoryProvider
|
||||
|
||||
cfg_path = tmp_path / "honcho.json"
|
||||
monkeypatch.setenv("HERMES_HOME", str(tmp_path))
|
||||
base = {"apiKey": "k", "peerName": "Igor", "aiPeer": "hermes"}
|
||||
provider = HonchoMemoryProvider()
|
||||
|
||||
cfg_path.write_text(json.dumps({**base, "sessionPeerPrefix": True, "sessionAiPeerPrefix": False}))
|
||||
sig_user_only = provider.identity_signature()["session_prefixing"]
|
||||
cfg_path.write_text(json.dumps({**base, "sessionPeerPrefix": True, "sessionAiPeerPrefix": True}))
|
||||
sig_both = provider.identity_signature()["session_prefixing"]
|
||||
|
||||
assert sig_user_only != sig_both
|
||||
|
||||
|
||||
class TestProfilePeerUniqueness:
|
||||
"""Each Hermes profile can pin to its own unique peerName.
|
||||
|
||||
Reference in New Issue
Block a user