Skip to content

The agent that grows with you

fix(search): resume deep compression lineages from the matched id, not the capped root walk

Yuan Lic004e97e3db1
diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/resolve-target-session.ts b/apps/desktop/src/app/session/hooks/use-prompt-actions/resolve-target-session.ts
index ce4ff405c21..acb1d9dd0cb 100644
--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/resolve-target-session.ts
+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/resolve-target-session.ts
@@ -104,6 +104,12 @@ export async function resolveTargetSessionId(deps: ResolveTargetSessionDeps): Pr
return requestGateway<{ session_id?: string }>('session.resume', {
session_id: storedTarget,
source: 'desktop',
+ // Same contract as every other desktop resume: the response must
+ // not inline a full compression lineage (deep ones exceed
+ // max_resume_messages and fail assert_resume_safe). Only the
+ // resolved tip session_id is consumed here; the gateway follows
+ // mid → tip itself (#125041).
+ omit_messages: true,
...(profile ? { profile } : {})
})
})
diff --git a/hermes_cli/web_routers/sessions.py b/hermes_cli/web_routers/sessions.py
index d35489735c5..3188bdc1a0a 100644
--- a/hermes_cli/web_routers/sessions.py
+++ b/hermes_cli/web_routers/sessions.py
@@ -335,13 +335,18 @@ async def search_sessions(
tip_cache: dict = {}
- def lineage_tip(root_id: str) -> str:
- if root_id not in tip_cache:
+ def lineage_tip(session_id: str) -> str:
+ # Resolve the tip from the MATCHED id, never from the lineage
+ # root: the forward chain walk is defensively bounded, so a
+ # lineage deeper than the bound truncates to a stale mid id
+ # when started at the root. Resuming from the matched id is
+ # what the CLI does and always reaches the live tip (#125041).
+ if session_id not in tip_cache:
try:
- tip_cache[root_id] = db.get_compression_tip(root_id) or root_id
+ tip_cache[session_id] = db.get_compression_tip(session_id) or session_id
except Exception:
- tip_cache[root_id] = root_id
- return tip_cache[root_id]
+ tip_cache[session_id] = session_id
+ return tip_cache[session_id]
# One keyspace for id-hits and content-hits, keyed by lineage root;
# first hit wins, and ID matches run first.
@@ -354,7 +359,7 @@ async def search_sessions(
if root in seen or len(seen) >= safe_limit:
return
payload = dict(payload)
- sid = lineage_tip(root)
+ sid = lineage_tip(raw_sid)
payload["session_id"] = sid
payload["lineage_root"] = root
payload["profile"] = row_profile
diff --git a/hermes_state_compression.py b/hermes_state_compression.py
index 3527c28e049..5523e9ed1f5 100644
--- a/hermes_state_compression.py
+++ b/hermes_state_compression.py
@@ -722,7 +722,10 @@ class SessionCompressionMixin:
current = session_id
chain = [current] if current else []
seen = set(chain)
- for _ in range(100): # defensive bound; chains this deep are pathological
+ # Defensive bound; ``seen`` guards cycles. 100 truncated real
+ # compression lineages (~180 deep), stranding root→tip walks on a
+ # stale mid id (#125041).
+ for _ in range(1000):
with self._read_ctx() as conn:
row = conn.execute(_CHAIN_STEP_SQL, (current,)).fetchone()
child_id = row["id"] if row is not None else None