fix(session_search): allow compression-ended parents in search results#13841
Open
iamagenius00 wants to merge 2 commits into
Open
fix(session_search): allow compression-ended parents in search results#13841iamagenius00 wants to merge 2 commits into
iamagenius00 wants to merge 2 commits into
Conversation
…rch results Compression-ended parent sessions contain content no longer in the agent's context window (replaced by a compact summary). The previous lineage exclusion logic skipped them along with delegation parents, creating a memory black hole for compacted content. Changes: - _resolve_to_parent() now returns (root_id, has_compression_hop), reusing the db.get_session() call already made during parent traversal (no extra queries) - Lineage exclusion skips delegation parents but allows compression parents - Tests: delegation exclusion, single compression, multi-level compaction 37 tests pass. Closes NousResearch#13840
|
I have verified this solution by inspecting the code changes and running the new test suite. The fix modifies to track whether a lineage chain includes a compression-ended session. It correctly excludes delegation parents (non-compression) from search results but includes compression-ended parents, whose content is no longer in the agent's context window. The new unit tests confirm that compression parents are searchable, while delegation parents remain excluded. This eliminates 'memory black holes' for compressed conversations. Tested and confirmed. ✅ |
19 tasks
14 tasks
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.
Summary
Allow compression-ended parent sessions to appear in
session_searchresults. After context compaction, the agent loses access to original messages (replaced by a compact summary), but the previous lineage exclusion logic skipped them — creating a memory black hole.Closes #13840
Supersedes #13501 (closed — this version addresses review concerns preemptively)
Related: #5447, #6256, #6507, #8803
What changed
tools/session_search_tool.py_resolve_to_parent()now returns(root_id, has_compression_hop)— checksend_reason == "compression"during the samedb.get_session()call it already makes for parent traversal (no additional DB queries)tests/tools/test_session_search.py(+3 tests)test_current_child_session_excludes_delegation_parent— delegation parents still excluded (renamed from old test, clarified intent)test_compression_parent_searchable— single-level compaction parent appears in resultstest_multi_level_compression_parent_searchable— A→B→C chain where both A and B are compression parentsDesign decisions
Why return a flag from
_resolve_to_parentinstead of a separate helper?The parent traversal already calls
db.get_session()for every hop. Checkingend_reasonin the same loop avoids N+1 queries that a separate_is_compression_session()helper would require.Why whitelist (allow compression) instead of blacklist (exclude delegation)?
Current implementation checks
not has_compression— if a futureend_reasontype is added where content is also lost, it would be excluded by default. This is the safer direction: new end_reasons default to excluded (same as current behavior), compression is the explicit exception. If more end_reasons need the same treatment, they can be added to the compression check.Testing
All 37 tests pass (34 existing + 2 new compression tests + 1 renamed delegation test).