Skip to content

The agent that grows with you

fix(honcho): describe what _seen_gateway_accounts can list

Erosika7dacc2ed3567
diff --git a/plugins/memory/honcho/cli.py b/plugins/memory/honcho/cli.py
index 22281c24ef2..672c7f23e35 100644
--- a/plugins/memory/honcho/cli.py
+++ b/plugins/memory/honcho/cli.py
@@ -1060,8 +1060,8 @@ def _state_db_path() -> Path:
def _seen_gateway_accounts(db_path: Path) -> list[dict]:
"""Gateway accounts recorded in state.db, most recent first; bot authors are skipped.
- The gateway stamps each session row with its routing peer, so grouping rows by
- (source, user_id) enumerates every account it has handled.
+ A session row keeps only its last routing peer, so a shared thread contributes
+ its most recent author and not every participant.
"""
if not db_path.exists():
return []
diff --git a/tests/honcho_plugin/test_peers_map.py b/tests/honcho_plugin/test_peers_map.py
index f89f2726be5..8943e036c25 100644
--- a/tests/honcho_plugin/test_peers_map.py
+++ b/tests/honcho_plugin/test_peers_map.py
@@ -51,6 +51,15 @@ class TestSeenGatewayAccounts:
{"platform": "telegram", "user_id": "111", "user_id_alt": "", "label": "eri", "sessions": 2, "profiles": []},
]
+ def test_shared_session_lists_only_its_last_author(self, tmp_path):
+ """record_gateway_session_peer overwrites the row's user_id, so earlier authors are gone."""
+ from hermes_state import SessionDB
+
+ db = SessionDB(tmp_path / "state.db")
+ for uid in ("alice", "bob"):
+ db.record_gateway_session_peer("shared", source="telegram", user_id=uid, session_key="telegram:group:1")
+ assert [a["user_id"] for a in _seen_gateway_accounts(tmp_path / "state.db")] == ["bob"]
+
def test_missing_db_or_table_returns_empty(self, tmp_path):
assert _seen_gateway_accounts(tmp_path / "absent.db") == []
sqlite3.connect(tmp_path / "empty.db").close()