Skip to content

The agent that grows with you

fix(clamps): raise profile fan-out limit to le=500 (simplify-pass finding)

kshitij200027887404
diff --git a/hermes_cli/web_routers/profiles.py b/hermes_cli/web_routers/profiles.py
index 13aea9fbcf0..d7bc45c2d81 100644
--- a/hermes_cli/web_routers/profiles.py
+++ b/hermes_cli/web_routers/profiles.py
@@ -56,10 +56,13 @@ _write_profile_model = late("_write_profile_model")
@sessions_router.get("/api/profiles/sessions")
def get_profiles_sessions(
- # ``le=100`` caps the per-request page size (idea from #39200) — this
+ # ``le=500`` caps the per-request page size (idea from #39200) — this
# endpoint fans the query out across EVERY profile's state.db, so an
- # unbounded limit multiplies the damage.
- limit: int = Query(20, ge=0, le=100),
+ # unbounded limit multiplies the damage. 500 (not 100) because real
+ # desktop callers use limit=200 (sessions-settings ARCHIVED_FETCH_LIMIT,
+ # command palette) and the electron remote-merge over-fetches
+ # ``limit + offset``.
+ limit: int = Query(20, ge=0, le=500),
offset: int = Query(0, ge=0),
min_messages: int = 0,
archived: str = "exclude",
diff --git a/tests/hermes_cli/test_dashboard_param_clamps.py b/tests/hermes_cli/test_dashboard_param_clamps.py
index 74c27f6ad43..96c9dfb9be8 100644
--- a/tests/hermes_cli/test_dashboard_param_clamps.py
+++ b/tests/hermes_cli/test_dashboard_param_clamps.py
@@ -39,6 +39,13 @@ class TestSessionPaginationClamps:
r = client.get("/api/profiles/sessions", params={"limit": 10_000})
assert r.status_code == 422
+ def test_profile_fanout_accepts_real_desktop_maximum(self, client):
+ # Desktop callers use limit=200 (ARCHIVED_FETCH_LIMIT, command
+ # palette) and electron over-fetches limit+offset — the clamp must
+ # sit ABOVE real client maxima, not break them.
+ r = client.get("/api/profiles/sessions", params={"limit": 200, "offset": 120})
+ assert r.status_code == 200
+
def test_in_range_limit_accepted(self, client):
r = client.get("/api/sessions", params={"limit": 50})
assert r.status_code == 200