fix(state): keep reset forks from stealing the compression lineage tip
A reset fork child (model_config._reset_from, or the legacy same-key heuristic) is a separate user-visible conversation that already lists as its own row, but the compression chain step only excluded branch/delegate/tool children. When a reset sibling ended later than the real continuation it won the last_active tiebreak, so the lineage tip projection landed on it: the newest session became invisible in every list and the reset sibling showed twice (#114271). Exclude _RESET_CHILD_SQL children in both forward-chain walkers (get_compression_chain's _CHAIN_STEP_SQL and the order_by_last_active CTE in list_sessions_rich), mirroring the resume path's exclusion.
This commit is contained in:
@@ -16,7 +16,7 @@ from agent.session_activity import (
|
||||
from hermes_startup_watchdog import report_startup_progress
|
||||
from hermes_state_common import (
|
||||
_LISTABLE_CHILD_SQL, _PREVIEW_ELIGIBLE_SQL, _PREVIEW_RAW_SELECT, _RECOVERABLE_END_REASONS,
|
||||
_RECOVERABLE_END_REASONS_SQL, _RESET_END_REASONS, _legacy_reset_child_sql, _shape_preview,
|
||||
_RECOVERABLE_END_REASONS_SQL, _RESET_CHILD_SQL, _RESET_END_REASONS, _legacy_reset_child_sql, _shape_preview,
|
||||
_sql_json_extract, _sql_session_last_active, _sql_session_last_active_by_id, escape_like as _escape_like,
|
||||
_SQL_IN_CHUNK, _id_chunks, _placeholders as _session_ids_placeholders,
|
||||
)
|
||||
@@ -1260,6 +1260,7 @@ class SessionSessionsMixin:
|
||||
WHERE parent.end_reason = 'compression'
|
||||
AND {_sql_json_extract('child.model_config', '$._branched_from')} IS NULL
|
||||
AND {_sql_json_extract('child.model_config', '$._delegate_from')} IS NULL
|
||||
AND NOT ({_RESET_CHILD_SQL.format(a='child')})
|
||||
AND COALESCE(child.source, '') != 'tool'
|
||||
),
|
||||
chain_max AS (
|
||||
|
||||
Reference in New Issue
Block a user