fix: allow session_search to find content from compression-ended parent sessions#13501
Closed
iamagenius00 wants to merge 1 commit into
Closed
Conversation
…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
2df403d to
28a517b
Compare
This was referenced Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
session_searchexcludes the entire current session lineage from results, including compression-ended parent sessions whose content the agent no longer has.After context compaction, the original messages from earlier in the conversation are summarized into a compact handoff. The agent loses access to specific details — but
session_searchstill treats those parent sessions as "current context" and skips them. This creates a memory black hole: the agent cannot recall compacted details even though they exist in the database.Why
Context compaction splits the active session:
end_reason="compression"The current lineage exclusion logic assumes all sessions in the lineage are still visible to the agent. After compaction, this assumption is wrong.
Reported independently in #5447, #6256, #6507, #8803.
What's included
tools/session_search_tool.py_is_compression_session()helper that checksend_reason == "compression"tests/tools/test_session_search.pytest_compression_parent_not_excluded_from_search— verifies that compression-ended parents appear in search resultsHow it works
Before:
After:
Testing