fix(gateway): tag remaining permanent loops out of the scale-to-zero busy check - #90594
Closed
benbarclay wants to merge 4 commits into
Closed
fix(gateway): tag remaining permanent loops out of the scale-to-zero busy check#90594benbarclay wants to merge 4 commits into
benbarclay wants to merge 4 commits into
Conversation
…busy check First live E2E after the supervised-watcher exclusion STILL never went dormant on staging: the loop-liveness heartbeat task is started directly in run() (not via _spawn_supervised), so it sits untagged in _background_tasks for the whole process life and holds _scale_to_zero_has_live_background_work() True forever. The gateway-wide heartbeat poller (_start_heartbeat_poller) is the same shape once any /heartbeat is registered. Tag both permanent loops with _hermes_supervised_watcher at their call sites. Transient tasks still block suspend. The heartbeat-poller test fails without the fix (exercises the real _start_heartbeat_poller call site, not a stubbed set).
Collaborator
Duplicate of #84558 — same two permanent heartbeat call sites, watcher tag mechanism, and scale-to-zero regression coverage. |
Collaborator
Author
|
Closing as a duplicate of #84558, which landed the same fix 8 days earlier (pierrenode) and is strictly better — its |
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
Follow-up to #84327 from the first live E2E run on staging (
hermes-agent-stg-test-6698, 2026-08-20, post-#84339 image): the instance armed at 05:56:56, went fully idle (only cron fires + housekeeping), and still never loggedgoing dormantafter 25+ minutes.Root cause
#84327 excluded
_spawn_supervisedwatchers from_scale_to_zero_has_live_background_work()— but two permanent loops are started directly withasyncio.create_task, parked in_background_tasks, and never tagged:_loop_heartbeat_task, started inrun()on every boot — confirmed alive on the staging box:state/gateway.heartbeatrefreshing every tick), and_start_heartbeat_poller, started once any/heartbeatis registered).The loop-liveness task alone is enough to hold the busy check True for the whole process life on every gateway, hosted or not.
Fix
Tag both call sites with
_hermes_supervised_watcher = True(the same tag_spawn_supervisedapplies). No behavioral change to either loop; transient tasks in_background_tasksstill block suspend. Audited the remaining_background_tasks.addsites: startup-resume events, plugin injection futures, completion-batch flushes, and supervised respawn helpers are all transient + self-discarding — correctly counted.Tests
test_heartbeat_poller_does_not_block_idle— exercises the real_start_heartbeat_pollercall site; fails on main (verified: 1 failed / 16 passed with the fix stashed), passes with the fix.test_loop_heartbeat_shape_is_excluded_when_tagged— the tagged-forever-task contract../scripts/run_tests.sh tests/gateway/test_scale_to_zero_watcher.py— 17 passed, 0 failed; ruff clean.Verification plan
Same staging E2E, after image roll:
going dormant ... then self-suspending+suspend accepted by flapsin agent.log within ~5–6 min of idle,suspension/suspended (flyd)in Fly events, Chronos cold-fire resume. (The instance's recurring 15-min cron leaves a ~9-min idle window — enough for the 5-min timeout.)Refs: #84295, #84327, #84339, NousResearch/nous-account-service#898.
Infographic