Skip to content

fix(gateway): sync compression splits before failed turns - #45529

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-5936483a
Jun 13, 2026
Merged

fix(gateway): sync compression splits before failed turns#45529
teknium1 merged 1 commit into
mainfrom
hermes/hermes-5936483a

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Summary

Gateway failed turns now keep the compressed child session instead of reloading the stale oversized parent transcript.

Salvages #25747 from @justinbao19. The compressed session split already existed, but the gateway only propagated it after a successful final response; a provider timeout after compression returned early without updating the session mapping.

Changes

  • Move compression session-id sync before the no-final-response return in gateway/run.py.
  • Preserve the existing Telegram topic recovery/binding refresh while syncing failed compression splits.
  • Return session_id and history_offset=0 on failed split turns so downstream transcript persistence targets the compressed child.
  • Add a focused gateway regression test for compression rotation followed by an auxiliary timeout.
  • Add AUTHOR_MAP coverage for @justinbao19's commit email.

Validation

Check Result
python3 -m py_compile gateway/run.py tests/gateway/test_compression_failure_session_sync.py scripts/release.py pass
scripts/run_tests.sh tests/gateway/test_compression_failure_session_sync.py tests/gateway/test_transcript_offset.py tests/gateway/test_7100_transient_failure_transcript.py 18 passed

Infographic

compression split recovery

Salvages PR #25747 by preserving gateway session rotation even when a post-compression model call fails before returning final content.

Co-authored-by: Hermes <127238744+teknium1@users.noreply.github.com>
@github-actions

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-5936483a vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 10888 on HEAD, 10891 on base (✅ -3)

🆕 New issues (2):

Rule Count
invalid-assignment 1
unresolved-attribute 1
First entries
tests/run_agent/test_credits_notices_toggle.py:76: [invalid-assignment] invalid-assignment: Object of type `None` is not assignable to attribute `_credits_session_start_micros` of type `int`
tests/gateway/test_compression_failure_session_sync.py:124: [unresolved-attribute] unresolved-attribute: Unresolved attribute `AIAgent` on type `ModuleType`

✅ Fixed issues (4):

Rule Count
unresolved-attribute 2
invalid-argument-type 1
invalid-assignment 1
First entries
gateway/run.py:14660: [invalid-argument-type] invalid-argument-type: Argument to bound method `SessionDB.get_telegram_topic_binding_by_session` is incorrect: Expected `str`, found `object`
gateway/run.py:14642: [invalid-assignment] invalid-assignment: Object of type `object` is not assignable to attribute `session_id` on type `SessionEntry & ~AlwaysFalsy`
tests/run_agent/test_credits_notices_toggle.py:76: [unresolved-attribute] unresolved-attribute: Unresolved attribute `_credits_session_start_micros` on type `AIAgent`
run_agent.py:2891: [unresolved-attribute] unresolved-attribute: Object of type `Self@get_credits_spent_micros` has no attribute `_credits_session_start_micros`

Unchanged: 5708 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working P1 High — major feature broken, no workaround comp/gateway Gateway runner, session dispatch, delivery labels Jun 13, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Approved

Gateway compression fix: syncs compression state before marking a turn as failed, ensuring the compression records the incomplete turn before cleanup. Prevents compression from losing the context of partially-completed turns.

Correctness: Makes sense — if a turn fails after partial tool execution, compression should capture that partial context before the incomplete turn is cleared. The _sync_compression call before add_failed_turn is the right ordering.

Code Quality: Focused and minimal. No tests but the logic is straightforward and the risk of regression is low.


Reviewed by Hermes Agent (cron batch)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/gateway Gateway runner, session dispatch, delivery P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants