fix(gateway): bound hygiene compression and fence late workers - #69866
Merged
Conversation
Contributor
૮ >ﻌ< ა ci reviewran on 62fcd86 ℹ️ InfoDesktop E2E visual evidence · View test artifacts · View job1 visual diff. inline evidence is publishing... |
… lookup + verify lock reacquire after fence cancel - gateway/run.py: use _adapter_for_source(source) instead of the raw adapters.get(source.platform) map so the compression-timeout warning respects transport provenance, relay ingress, and multiplexed profiles (matches every other user-facing send in the hygiene block). - tests: add a lock-release verification regression — a fence-cancelled hygiene compression must leave the per-session compression lock free so the next attempt (manual /compress retry) acquires it and commits normally.
teknium1
force-pushed
the
salvage/53380-hygiene-bounds
branch
from
July 23, 2026 05:16
a5b3cd3 to
62fcd86
Compare
19 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.
Summary
Gateway pre-agent hygiene compression is now bounded: an incoming message never blocks indefinitely on a slow/broken auxiliary compression backend, and a worker that outlives the timeout is fenced so it can never mutate session state late. Root cause: the hygiene pre-sweep awaited
run_in_executorwith no bound, andwait_for()alone would only bound the await — the executor thread keeps running, so the timeout path needed a commit fence, deferred temp-agent cleanup, and lock-release guarantees.Changes
agent/conversation_compression.py: newCompressionCommitFence(cancellation token with a deterministic commit boundary);compress_contextchecks the fence immediately before any session mutation — a cancelled worker becomes a no-op that returns the input unchanged, resets_last_compaction_in_place, emits abort telemetry, and releases the per-session compression lock.gateway/run.py: hygiene pre-sweep now usesasyncio.wait_for(asyncio.shield(...), timeout=compression.hygiene_timeout_seconds); on timeout it cancels via the fence (or consumes the result if the worker already crossed the commit boundary), warns the user, records a per-session failure cooldown, and defers temp-agent cleanup until the executor future actually finishes (_defer_agent_cleanup_until_future_done) so live clients are never torn down under a running thread. Per-session failure cooldown also set on compression aborts. Timeout warning delivered via the profile-aware_adapter_for_source.hermes_cli/config.py+website/docs/user-guide/configuration.md:compression.hygiene_timeout_seconds(30) andcompression.hygiene_failure_cooldown_seconds(300) knobs.run_agent.py:_compress_contextforwardscommit_fence.Validation
hygiene_timeout_seconds, user warned, turn continues/compressacquires and commitstargeted tests:
tests/gateway/ -k hygiene39 passed;tests/agent/test_compression_concurrent_fork.py+tests/gateway/test_session_hygiene.py71 passed, 0 failed.Credit
Salvaged from #53380 by @westkite1201; worker fencing added during salvage.
Infographic