You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recovers legacy or malformed sessions that are marked end_reason=compression but have no continuation row. Current compression publication is already atomic, so this does not replace or weaken that path; it adds a conservative repair for orphaned state that can otherwise reject every future transcript write.
At turn start, Hermes still prefers adopting the unique live compression child. If none exists, the new database operation reopens the parent only when one write transaction confirms all of these invariants:
the parent is compression-ended
no active compression lease exists
no canonical continuation child exists, including an ended child
If a child or active lease exists, recovery remains fail-closed rather than guessing which session owns subsequent messages. Branch, delegate, and tool children do not count as compression continuations.
alt-glitch
added
type/bug
Something isn't working
P1
High — major feature broken, no workaround
comp/agent
Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint
area/sessions
Session lifecycle, resume, persistence, history
area/compression
Context compression and continuation sessions
sweeper:risk-session-state
Sweeper risk: may lose/corrupt/mis-associate session or context state
labels
Aug 6, 2026
Merged via #80487 with your commits cherry-picked and authorship preserved (rebase-merge — both fix(sessions): recover compression parents without continuations and fix(sessions): fence expired orphan recovery leases are on main under your name). Thank you — the transactional lineage+lease guards and the refresh-vs-reclaim fencing were the right design, and adversarial review confirmed the BEGIN IMMEDIATE serialization holds against a late compressor.
One follow-up commit rode along in the salvage: compression continuations inherit the rotated agent's model_config verbatim, so a delegate subagent's continuation carries a foreign _delegate_from — the marker-presence filters misread that as a delegate child (reopen would have forked the lineage). The markers are now bound to the queried parent via a shared SQL fragment used by both find_live_compression_child and the reopener, with a regression pair covering both directions.
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
area/compressionContext compression and continuation sessionsarea/sessionsSession lifecycle, resume, persistence, historycomp/agentCore agent runtime: loop, agent_init, prompt builder, context-compression, responses endpointP1High — major feature broken, no workaroundsweeper:risk-session-stateSweeper risk: may lose/corrupt/mis-associate session or context statetype/bugSomething isn't working
3 participants
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 does this PR do?
Recovers legacy or malformed sessions that are marked
end_reason=compressionbut have no continuation row. Current compression publication is already atomic, so this does not replace or weaken that path; it adds a conservative repair for orphaned state that can otherwise reject every future transcript write.At turn start, Hermes still prefers adopting the unique live compression child. If none exists, the new database operation reopens the parent only when one write transaction confirms all of these invariants:
If a child or active lease exists, recovery remains fail-closed rather than guessing which session owns subsequent messages. Branch, delegate, and tool children do not count as compression continuations.
Related Issue
Fixes #80337
Related: #71001 established atomic parent/child publication for new compression rotations.
Type of Change
Changes Made
SessionDB.reopen_orphaned_compression_session()with transactionally checked lineage and lease guards.How to Test
end_reason=compressionwithout creating a child.Validation
pytest -q tests/state tests/agent/test_compression*.py- 151 passedruff checkon changed Python filesgit diff --checkChecklist