Skip to content

fix(search): include compression parents in session_search results#6256

Open
MacroAnarchy wants to merge 1 commit into
NousResearch:mainfrom
MacroAnarchy:fix/session-search-compression-parents
Open

fix(search): include compression parents in session_search results#6256
MacroAnarchy wants to merge 1 commit into
NousResearch:mainfrom
MacroAnarchy:fix/session-search-compression-parents

Conversation

@MacroAnarchy

Copy link
Copy Markdown
Contributor

Bug

After context compression (/compress, hygiene auto-compression, or mid-run compression), the parent session's full transcript is summarized away — the agent no longer has that content in its context window. Yet session_search excluded the entire lineage root, making hours of pre-compression conversation completely invisible to search.

This was especially painful for long gateway sessions that compress multiple times: each compression split made progressively more history unsearchable.

Root Cause

_resolve_to_parent() walks UP the compression chain to find the root session. The code then excluded ALL sessions matching that root — including the compression parent whose content was already lost to summarization.

Fix

Only exclude raw_sid == current_session_id (the actual live session). Do not exclude compression parents — their content was compressed away and is no longer in the agent's context, so it SHOULD be searchable.

Dedup via _resolve_to_parent still works correctly for grouping child sessions for summarization.

Testing

  • All 25 existing tests pass (with 2 updated to reflect corrected behavior)
  • Live-tested on a production gateway session: compression parents that were previously invisible now appear correctly in search results
  • Current session exclusion still works (verified)

Files Changed

  • tools/session_search_tool.py — 7 lines removed, 6 added (net -1 line)
  • tests/tools/test_session_search.py — tests updated to match corrected behavior

After context compression, the parent session's full transcript is
summarized away — the agent no longer has that content.  Yet
session_search excluded the entire lineage root, making hours of
pre-compression conversation invisible to search.

This was especially painful for long gateway sessions that compress
multiple times: each compression split made more history unsearchable.

Fix: only exclude the current session_id itself, not its compression
parents.  Dedup via _resolve_to_parent still groups child sessions
correctly for summarization.
iamagenius00 added a commit to iamagenius00/hermes-agent that referenced this pull request Apr 21, 2026
…nt sessions

Context compaction splits the active session: the parent is closed with
end_reason='compression' and a new child becomes the active session. The
parent's messages are summarized into a compact handoff, and the original
messages are no longer in the agent's context window.

Previously, session_search excluded the entire current session lineage,
including compression-ended parents. This created a 'memory black hole' —
the agent could not recall specific details from compacted portions of the
conversation, even though those messages still exist in the database.

The fix narrows the exclusion: only skip sessions in the current lineage
whose content the agent still has access to. Compression-ended sessions
are no longer excluded, since their original content is gone from context
and should be recoverable via search.

Closes NousResearch#5447, NousResearch#6256, NousResearch#6507, NousResearch#8803
@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/agent Core agent loop, run_agent.py, prompt builder tool/memory Memory tool and memory providers duplicate This issue or pull request already exists labels Apr 30, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13841 — same fix for #13840 (compression-parent sessions excluded from session_search).

@alt-glitch

Copy link
Copy Markdown
Collaborator

Likely duplicate of #13841 — same fix: narrow lineage exclusion to allow compression-ended parents in session_search results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent loop, run_agent.py, prompt builder duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists tool/memory Memory tool and memory providers type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants