fix(gateway): resume follows the compression tip so post-compression replies render - #48633
Merged
Conversation
…replies render Auto-compression ends the live session and forks a continuation child (linked via parent_session_id). A long-lived parent keeps its own flushed message rows, so resolve_resume_session_id()'s empty-head walk never redirected it — resuming the parent id reloaded the pre-compression transcript and dropped every turn generated after compression, including the assistant's response. On the desktop this is the recurring "I sent a message, came back, and the reply isn't there" report on large sessions: the chat's routed id is the pre-rotation id, and both the gateway session.resume RPC and the REST /messages read anchored on it. Fix the resolver at the chokepoint: resolve_resume_session_id() now follows the compression-continuation chain forward via get_compression_tip() before its existing empty-head descendant walk. get_compression_tip() only follows children whose parent ended with end_reason='compression' (created after the parent was ended), so delegation/branch children never hijack a resume. This fixes every resume caller at once (REST /messages, CLI --resume, gateway /resume). session.resume in tui_gateway was the one resume path that never called the resolver — it used the raw target id directly. Route it through resolve_resume_session_id() too (non-lazy only; lazy watch windows must stay on their exact child branch). Resolving up front also re-anchors the live-session fast path so a still-live rotated session is reused by its new key instead of rebuilding a duplicate agent on the stale parent. Tests: - resolve_resume_session_id follows the tip even when the parent retains messages, and is not confused by a delegation child. - session.resume binds the agent to the continuation tip and returns the post-compression reply.
Contributor
🔎 Lint report:
|
…access The new compression-tip tests poke started_at/ended_at directly via db._conn to force deterministic lineage ordering. _conn is typed Optional[Connection], so ty flagged .execute/.commit as unresolved on None. Bind a local and assert it's non-None first to narrow the union.
OutThisLife
enabled auto-merge
June 18, 2026 21:08
4 tasks
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
…llows-compression-tip fix(gateway): resume follows the compression tip so post-compression replies render
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
…llows-compression-tip fix(gateway): resume follows the compression tip so post-compression replies render
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
…llows-compression-tip fix(gateway): resume follows the compression tip so post-compression replies render
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
…llows-compression-tip fix(gateway): resume follows the compression tip so post-compression replies render
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
…llows-compression-tip fix(gateway): resume follows the compression tip so post-compression replies render
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
Fixes the recurring desktop report: "I send a message, it starts working, I look away, and when I come back the reply isn't there" — on large sessions, the response is generated and persisted but never shows up under the user's message.
Root cause is session rotation on auto-compression, not a render bug:
parent_session_id); the turns generated after compression — including the assistant's response — land in the continuation, not the original session.SessionDB.resolve_resume_session_id()only redirected an empty head to a descendant (the--resumeloads empty chat after context compression; exit banner points at wrong session id #15000 case). A long-lived parent keeps its own flushed message rows, so it was never redirected — and every resume path anchored on the parent id reloaded the pre-compression transcript, missing the response.session.resumeRPC and the REST/messagesread missed the continuation.Changes
hermes_state.resolve_resume_session_id()now follows the compression-continuation chain forward via the existingget_compression_tip()before its empty-head walk.get_compression_tip()is lineage-aware (only follows children whose parent ended withend_reason='compression', created after the parent was ended), so delegation/branch children never hijack a resume. This fixes every resume caller at the chokepoint: REST/messages, CLI--resume, gateway/resume.tui_gatewaysession.resumewas the one resume path that bypassed the resolver (it used the rawtargetid). It now routes throughresolve_resume_session_id()(non-lazy only — lazy watch windows must stay on their exact child branch). Resolving up front also re-anchors the live-session fast path, so a still-live rotated session is reused by its new key instead of rebuilding a duplicate agent on the stale parent.Premise verification
tests/hermes_state/test_resolve_resume_session_id.py::test_follows_compression_tip_when_parent_retains_messagesfails on currentmain(resolve_resume_session_id("root")returns"root", the pre-compression parent) and passes with this change.Test plan
resolve_resume_session_idfollows the tip even when the parent retains messages; not confused by a delegation childsession.resumebinds the agent to the continuation tip and returns the post-compression replytests/hermes_cli/test_web_server.py,tests/cli/test_cli_resume_command.py,tests/cli/test_resume_display.py,tests/cli/test_resume_quiet_stderr.py,tests/gateway/test_resume_command.py,tests/test_lazy_session_regressions.py,tests/test_hermes_state.py,tests/test_tui_gateway_server.py(only the unrelated, environment-dependenttest_browser_manage_connect_default_local_reports_launch_hintfails locally — no Chromium on the box)Follow-up (not in this PR, to keep it one idea)
The desktop prefers the REST
/messagessnapshot over the resume payload when non-empty; with the resolver fixed both now agree. A separate cleanup could make the gateway re-anchor_find_live_session_by_keyto also match a session's pre-rotation id directly, but resolving the tip up front already covers the reuse path.