Skip to content

The agent that grows with you

fix(honcho): keep _pop_auth_notice tolerant of minimal fake managers; make fast-path test binding

kshitij520a1e78128c
diff --git a/plugins/memory/honcho/__init__.py b/plugins/memory/honcho/__init__.py
index 030f0a4cd9d..ea24ed064fc 100644
--- a/plugins/memory/honcho/__init__.py
+++ b/plugins/memory/honcho/__init__.py
@@ -883,7 +883,10 @@ class HonchoMemoryProvider(MemoryProvider):
def _pop_auth_notice(self) -> str:
"""One-time model-facing notice that Honcho auth expired and memory is paused."""
- msg = self._manager.pop_auth_notice() if self._manager else None
+ # getattr (not a direct call): test fakes install minimal managers
+ # without pop_auth_notice; exceptions still propagate.
+ pop = getattr(self._manager, "pop_auth_notice", None)
+ msg = pop() if callable(pop) else None
if not isinstance(msg, str) or not msg:
# Init failures discard the manager; the provider kept the detail.
if self._init_auth_failure is None or self._init_auth_notice_emitted:
diff --git a/tests/honcho_plugin/test_auth_recovery.py b/tests/honcho_plugin/test_auth_recovery.py
index bf76a9913e1..ae1c3799f8e 100644
--- a/tests/honcho_plugin/test_auth_recovery.py
+++ b/tests/honcho_plugin/test_auth_recovery.py
@@ -50,6 +50,17 @@ def _rotated_body(n=1):
}
[email protected](autouse=True)
+def _reset_oauth_module_state():
+ """Module-level oauth dicts persist across tests in one process; reset so
+ dead grants / cooldowns / memoized verdicts can't leak between tests."""
+ yield
+ oauth._dead_grants.clear()
+ oauth._refresh_failure_at.clear()
+ oauth._reauth_check_cache.clear()
+ oauth._expiry_cache.clear()
+
+
# ---------------------------------------------------------------------------
# oauth: transient vs permanent exchange failures
# ---------------------------------------------------------------------------
@@ -1139,10 +1150,17 @@ class TestClientGenerationGuard:
oauth._dead_grants.clear()
- def _fail():
- raise AssertionError("resolve_config_path must not run on the fast path")
+ # Recording spy, not a raising stub: _reauth_required swallows all
+ # exceptions, so a raise would be silently converted to False and the
+ # test would pass even without the fast path.
+ calls = []
+
+ def _spy():
+ calls.append(1)
+ return Path("/nonexistent/honcho.json")
- monkeypatch.setattr(client_mod, "resolve_config_path", _fail)
+ monkeypatch.setattr(client_mod, "resolve_config_path", _spy)
cfg = HonchoClientConfig(host="hermes", api_key="hch-at-x", enabled=True)
mgr = HonchoSessionManager(config=cfg)
assert mgr._reauth_required() is False
+ assert calls == [], "resolve_config_path must not run on the fast path"