fix(gateway): forward-resolve compressed session to tip on resident non-Telegram platforms - #48911
Closed
RoySRose wants to merge 1 commit into
Closed
Conversation
…nt platforms Compaction rotates session_id (ends parent with end_reason=compression, creates child). The forward-resolution that heals stale session_key->session_id mappings existed only inside the Telegram-topic-lane branch, so Discord/Slack resident gateways reloaded the pre-compression parent on the next message -> the stale oversized parent re-grows past the context cap and forks orphan child sessions in an endless preflight-compression loop (observed on hermes-main: one session reached 283K tokens > cap, 3 orphan children in ~80min). Apply the same get_compression_tip() walk (already used by the Telegram lane and proven by tests) to the general non-Telegram path right after get_or_create_session, so the next message resumes the compressed child. Idempotent and safe: get_compression_tip only follows end_reason='compression' chains and returns the input unchanged otherwise. Refs NousResearch#44004 NousResearch#38763 NousResearch#25921.
Contributor
|
Thanks for identifying the resident-gateway compression-routing failure mode. This is now implemented on current
This is an automated hermes-sweeper review. |
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 resident-gateway (Discord/Slack) slice of the compaction session-fork bug (#44004): on a self-hosted Discord/Slack gateway, a long conversation keeps rotating its
session_idon every auto-compression, forking orphan child sessions and reloading the oversized pre-compression parent on each turn — an endless preflight-compression loop where one session was observed climbing past the model's context cap and spawning multiple orphan lineages in minutes.Why existing fixes don't cover this path
The same #44004 root cause has three distinct intake paths, each needing its own forward-resolution to the compression tip:
SessionDB.resolve_resume_session_id()+ TUI/desktop resume (tui_gateway/server.py).gateway/platforms/api_server.py, stateless OpenAI-compatible clients.GatewayRunner._handle_message()→session_store.get_or_create_session()ingateway/run.py.The resident gateway path never calls
resolve_resume_session_id()(only slash-commands / TUI / api_server do), andget_or_create_session()returns the storedsession_key → session_idmapping verbatim without following the compression chain. The only forward-resolution ingateway/run.pylived inside the Telegram-topic-lane branch, so Discord/Slack resident lanes reloaded the pre-compression parent after every rotation.Change
Right after
get_or_create_session(), apply the same lineage-awareget_compression_tip()walk the Telegram lane already uses — for all non-Telegram resident platforms — andswitch_session()thesession_keyforward to the tip. Telegram keeps its own binding-based healing.get_compression_tip()only followsend_reason='compression'chains and returns the input unchanged otherwise, so it's a no-op for fresh/branch/delegate sessions.Verification
tests/test_hermes_state.py -k compression_tip(4 passed) — the primitive.tests/gateway/test_telegram_topic_mode.py(44 passed) — the mirrored healing pattern, no regression.Refs #44004, complements #48633 and #44103.