fix(gateway): harden scale-to-zero dormancy guards - #52359
Merged
Conversation
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
Contributor
🔎 Lint report:
|
tonydwb
approved these changes
Jun 25, 2026
tonydwb
left a comment
There was a problem hiding this comment.
Code Review Summary
Verdict: Approved
This PR hardens the scale-to-zero dormancy guards in the gateway. Two key changes:
active_count()fromtools.async_delegationis checked to prevent suspending while background delegations are active_scale_to_zero_note_real_inbound()stamps real inbound traffic and restores lifecycle status after a dormant wake
Key observations
- Async delegation check prevents suspend while background tasks run
- Real inbound note prevents status from being stuck in
drainingafter wake - Internal completion/replay events intentionally do NOT call the helper
- Good test coverage for both changes
Looks Good
- Fail-closed design with defensive exception handling
- Proper separation between real traffic and internal events
- Tests verify the status restoration behavior
Reviewed by Hermes Agent (cron)
pai-scaffolde
pushed a commit
to pai-scaffolde/hermes-agent
that referenced
this pull request
Jun 28, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
1 task
waefrebeorn
pushed a commit
to waefrebeorn/slermes
that referenced
this pull request
Jul 2, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
habarmc1223-sudo
pushed a commit
to habarmc1223-sudo/hermes-agent-fluxmem
that referenced
this pull request
Jul 8, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
santhreal
pushed a commit
to santhreal/hermes-agent
that referenced
this pull request
Jul 13, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
Gravezzz
pushed a commit
to Gravezzz/hermes-agent
that referenced
this pull request
Jul 21, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
leewenjie
pushed a commit
to leewenjie/hermes-agent
that referenced
this pull request
Aug 7, 2026
Block scale-to-zero suspend while background async delegations are active, and restore runtime status to running on real inbound after a dormant wake.\n\nAdd regression coverage for both review findings.
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
delegate_task(background=true)async delegations are still running.drainingback torunningon the first real inbound after a dormant wake.Test Plan
uv run --extra dev python -m pytest tests/gateway/test_scale_to_zero.py tests/gateway/test_scale_to_zero_watcher.py tests/gateway/relay/test_relay_going_idle.py -q -o 'addopts='python -m compileall -q gateway/run.py tests/gateway/test_scale_to_zero_watcher.pygit diff --check origin/main -- gateway/run.py tests/gateway/test_scale_to_zero_watcher.py