Skip to content

fix: allow session_search to find content from compression-ended parent sessions#13501

Closed
iamagenius00 wants to merge 1 commit into
NousResearch:mainfrom
iamagenius00:fix/session-search-compression-exclusion
Closed

fix: allow session_search to find content from compression-ended parent sessions#13501
iamagenius00 wants to merge 1 commit into
NousResearch:mainfrom
iamagenius00:fix/session-search-compression-exclusion

Conversation

@iamagenius00

Copy link
Copy Markdown
Contributor

What

session_search excludes 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_search still 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:

  1. The parent session is closed with end_reason="compression"
  2. A new child session becomes the active session
  3. The parent's messages are replaced by a summary in the agent's context

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

  • Added _is_compression_session() helper that checks end_reason == "compression"
  • Narrowed the lineage exclusion: sessions ended by compression are no longer skipped, since their content is gone from the agent's context window
  • Delegation children (non-compression) are still properly excluded

tests/tools/test_session_search.py

  • Renamed existing test to clarify it covers delegation parents only
  • Added test_compression_parent_not_excluded_from_search — verifies that compression-ended parents appear in search results
  • All 36 tests pass

How it works

Before:

if current_lineage_root and resolved_sid == current_lineage_root:
    continue  # skips ALL sessions in current lineage

After:

if current_lineage_root and resolved_sid == current_lineage_root:
    if not _is_compression_session(raw_sid):
        continue  # only skip if content is still in agent's context

Testing

$ python -m pytest tests/tools/test_session_search.py -v
36 passed in 1.54s

…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
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 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