The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(sessions): page aggregate lists past 500 rows
Shawn Wang4da9edd79f08
diff --git a/hermes_cli/web_routers/profiles.py b/hermes_cli/web_routers/profiles.pyindex d8e384c72ff..aa1c3487a49 100644--- a/hermes_cli/web_routers/profiles.py+++ b/hermes_cli/web_routers/profiles.py@@ -476,8 +476,11 @@ def get_profiles_sessions(exclude_sources=_csv_list(exclude_sources) or None, min_message_count=max(0, min_messages),include_archived=archived == "include", archived_only=archived == "only")# Over-fetch per profile so the merged+sorted window is correct for the requested page.- # Capped so a huge profile can't blow up the response.- per_profile = min(max(limit + offset, limit), 500)+ # ``limit`` is already bounded to 500 by FastAPI; the offset is caller-controlled+ # pagination state, so include it instead of capping the source window at 500.+ # Otherwise page 3 of a 577-row profile is permanently empty even though ``total``+ # reports the remaining rows.+ per_profile = limit + offsetmerged: List[Dict[str, Any]] = []totals: Dict[str, int] = {}diff --git a/tests/hermes_cli/test_web_server.py b/tests/hermes_cli/test_web_server.pyindex 4543bb78296..9157381ec55 100644--- a/tests/hermes_cli/test_web_server.py+++ b/tests/hermes_cli/test_web_server.py@@ -2565,6 +2565,30 @@ CONFIG_SCHEMA = ProviderConfigSchema(assert payload["limit"] == 3assert len(payload["sessions"]) == 3+ def test_profiles_sessions_pages_past_500_rows(self):+ """The aggregate route must not strand rows after its old 500-row+ per-profile source cap (issue #88438)."""+ from hermes_state import SessionDB++ db = SessionDB()+ try:+ for i in range(501):+ sid = f"archived-page-{i:03d}"+ db.create_session(session_id=sid, source="cli")+ db.append_message(session_id=sid, role="user", content="hi")+ db.set_session_archived(sid, True)+ finally:+ db.close()++ resp = self.client.get(+ "/api/profiles/sessions?limit=1&offset=500&archived=only&profile=default"+ )+ assert resp.status_code == 200+ payload = resp.json()+ assert payload["total"] == 501+ assert len(payload["sessions"]) == 1+ assert payload["offset"] == 500+def test_get_session_messages_rejects_negative_limit(self):"""limit=-1 previously bypassed the documented 500-row clamp becausemin(-1, 500) == -1, which SQLite treats as 'no limit'."""