Skip to content

The agent that grows with you

fix(honcho): read an author join's observation flags through one manager method

Erosikabcac7e94650c
diff --git a/plugins/memory/honcho/session.py b/plugins/memory/honcho/session.py
index 00d8b0f883c..5c54fdd5f8c 100644
--- a/plugins/memory/honcho/session.py
+++ b/plugins/memory/honcho/session.py
@@ -249,6 +249,11 @@ class HonchoSessionManager(SessionAuthMixin, SessionPeersMixin, SessionContextMi
# ----- Writes -----
+ def _join_observation_flags(self, honcho_session_id: str) -> tuple[bool, bool]:
+ """(observe_me, observe_others) for an author peer joining ``honcho_session_id``."""
+ # Manager-wide today. #103889 stores the effective flags per session and plugs in here.
+ return self._user_observe_me, self._user_observe_others
+
def _author_peer_for_session(self, honcho_session: Any, honcho_session_id: str, author_peer_id: str) -> Any:
"""The author's peer, joined to the session the first time it writes.
@@ -259,7 +264,8 @@ class HonchoSessionManager(SessionAuthMixin, SessionPeersMixin, SessionContextMi
return peer
try:
from honcho.session import SessionPeerConfig
- config = SessionPeerConfig(observe_me=self._user_observe_me, observe_others=self._user_observe_others)
+ observe_me, observe_others = self._join_observation_flags(honcho_session_id)
+ config = SessionPeerConfig(observe_me=observe_me, observe_others=observe_others)
honcho_session.add_peers([(peer, config)])
except Exception as e:
# The write still lands under the right peer. Only the membership (observe config) is missing.
diff --git a/tests/honcho_plugin/test_turn_author_peers.py b/tests/honcho_plugin/test_turn_author_peers.py
index f7b78c0d63d..4a05bf22fa9 100644
--- a/tests/honcho_plugin/test_turn_author_peers.py
+++ b/tests/honcho_plugin/test_turn_author_peers.py
@@ -260,6 +260,27 @@ class TestFlushAttributesMessages:
# Not remembered as joined, so the next write retries the join.
assert "alice" not in mgr._joined_author_peers.get(session.honcho_session_id, set())
+ def test_join_uses_the_sessions_observation_flags(self):
+ """The join reads its flags through _join_observation_flags, the seam #103889 fills per session."""
+ mgr = _manager(_config(user_observe_me=True, user_observe_others=True), runtime_id="7654321")
+ session = self._session(mgr)
+ honcho_session = MagicMock()
+ mgr._sessions_cache[session.honcho_session_id] = honcho_session
+ seen: list[str] = []
+
+ def _flags(honcho_session_id):
+ seen.append(honcho_session_id)
+ return False, False
+
+ mgr._join_observation_flags = _flags
+
+ session.add_message("user", "alice speaking", author_peer_id="alice")
+ assert mgr._flush_session(session) is True
+
+ assert seen == [session.honcho_session_id]
+ (_peer, config), = honcho_session.add_peers.call_args[0][0]
+ assert (config.observe_me, config.observe_others) == (False, False)
+
class TestProviderReadsTheAuthor:
def _provider(self) -> HonchoMemoryProvider: