Skip to content

The agent that grows with you

fix(honcho): list gateway accounts whose session rows predate session_key

Erosika506dcacd9f14
diff --git a/plugins/memory/honcho/cli.py b/plugins/memory/honcho/cli.py
index 8fe21c52dcd..17deb242370 100644
--- a/plugins/memory/honcho/cli.py
+++ b/plugins/memory/honcho/cli.py
@@ -1080,7 +1080,6 @@ def _seen_gateway_accounts(db_path: Path) -> list[dict]:
COUNT(*){profiles_col}
FROM sessions
WHERE user_id IS NOT NULL AND user_id != ''
- AND session_key IS NOT NULL AND session_key != ''
GROUP BY source, user_id
ORDER BY MAX(COALESCE(started_at, 0)) DESC"""
try:
diff --git a/tests/honcho_plugin/test_peers_map.py b/tests/honcho_plugin/test_peers_map.py
index d0289c0b1a2..2e5ff3c2e6a 100644
--- a/tests/honcho_plugin/test_peers_map.py
+++ b/tests/honcho_plugin/test_peers_map.py
@@ -79,6 +79,17 @@ class TestSeenGatewayAccounts:
accounts = _seen_gateway_accounts(db)
assert [a["user_id"] for a in accounts] == ["111"]
+ def test_legacy_rows_without_session_key_still_count(self, tmp_path):
+ """Gateway rows written before session_key was stamped are still accounts."""
+ db = tmp_path / "state.db"
+ _make_state_db(db, [
+ ("s1", "telegram", "111", None, "Eri", None, 100.0),
+ ("s2", "telegram", "111", "", "Eri", None, 200.0),
+ ])
+ accounts = _seen_gateway_accounts(db)
+ assert [a["user_id"] for a in accounts] == ["111"]
+ assert accounts[0]["sessions"] == 2
+
def test_label_falls_back_to_display_name(self, tmp_path):
db = tmp_path / "state.db"
_make_state_db(db, [