fix(gateway): preserve compressed session in queued follow-ups - #79322
Open
richkapp wants to merge 1 commit into
Open
fix(gateway): preserve compressed session in queued follow-ups#79322richkapp wants to merge 1 commit into
richkapp wants to merge 1 commit into
Conversation
Collaborator
richkapp
force-pushed
the
fix/queued-followup-compression-session
branch
from
August 5, 2026 12:30
8028d69 to
2af1da3
Compare
richkapp
force-pushed
the
fix/queued-followup-compression-session
branch
from
August 5, 2026 12:41
2af1da3 to
f9f8231
Compare
9 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.
What changed
Queued follow-up turns now continue on the live session returned by the immediately preceding turn. Previously, when that turn compressed its transcript, the recursive follow-up reused the closed parent session and failed with
CompressionSessionClosedError.The effective session now drives:
/goalactivity checksWhen an active goal must move from the compressed parent to its continuation, the state transfer is now one
BEGIN IMMEDIATEtransaction with source-value CAS and a destination-absent guard. A partial write rolls back, and a child pause/clear cannot be overwritten. If goal state is temporarily unreadable, the synthetic continuation is retried once and then parked in FIFO rather than silently discarded or hot-looped.The cached-agent snapshot advances parent→child only when that same cached agent reports the returned child session, preserving warm-prefix reuse without weakening stale/dead-session eviction.
If a result omits
session_id, behavior still falls back to the original session.Why
Compression closes the parent session and publishes a live continuation. Reusing the parent for a queued message risks a persistence failure even though storage, permissions, and the database are healthy. Goal migration also has to preserve user control and survive partial writes; otherwise a queued synthetic continuation can vanish during the same rotation boundary.
Tests
HERMES_TEST_FILE_RETRIES=0 scripts/run_tests.sh tests/gateway/test_agent_cache.py tests/gateway/test_queued_native_image_session_key.py tests/gateway/test_session_id_cache_coherence.py tests/gateway/test_first_turn_session_meta_rebaseline.py tests/gateway/test_goal_continuation_drain.py tests/hermes_cli/test_goals.py tests/gateway/test_compression_session_id_persistence.py tests/agent/test_compression_rotation_state.py tests/state/test_compression_lineage_guard.py tests/gateway/test_transcript_offset.py tests/gateway/test_queue_consumption.py -q— 122 passedruff check gateway/run.py hermes_cli/goals.py hermes_state.py tests/gateway/test_queued_native_image_session_key.py tests/hermes_cli/test_goals.pygit diff --checkRegression coverage includes the rotated-session route, non-null-parent missing-result fallback, cache re-baselining, queued-goal call-site ID forwarding, real-DB migration, rollback after an injected archive failure, paused/cleared child preservation, strict read-error handling, and bounded retry/FIFO parking.