Repository navigation
fix(gastown): stop containers when no agent is running - #8613
Merged
Merged
Conversation
The alarm kept a town's container awake while hasActiveWork was true. That includes beads the reconciler never dispatches, such as held issues or triage requests behind a stuck batch, so those containers ran forever. Only a working or recently stalled agent now keeps the container awake, gets the health probe, or gets the hourly token refresh. Other work starts the container when it is dispatched. Alarm cadence still uses hasActiveWork.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Assumptions: Files Reviewed (5 files)
Reviewed by deepseek-flash-latest · Input: 132.6K · Output: 31.4K · Cached: 2.8M Review guidance: REVIEW.md from base branch |
iscekic
approved these changes
Oct 22, 2026
This was referenced Oct 23, 2026
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
Gastown containers stayed awake in towns where nothing was happening. The TownDO alarm kept a container awake while
hasActiveWorkwas true. That rule also counts beads the reconciler never dispatches, for example held issues, or triage requests waiting behind a stuck triage batch. Production logs showed 242 towns with a running container, and only 6 of them did any agent work in 2 hours.scheduling.hasRunningAgentsis the rule for "an agent process should be running": an agent that isworking, orstalledfor less than 30 minutes.hasActiveWorkuses it too, so the query has one owner.ensureContainerReady: the warm-up and the/healthprobe on every tick.stopContainerIfIdle: the idle stop.refreshContainerToken: the hourly/refresh-tokenrequest. In production, a request to a stopped container starts it again.prepareContainerBilling→warmUp, as it already does aftersleepAfter. The alarm cadence and the reconciler still usehasActiveWork.stopContainerIfIdle: stopped idle container, so you can count stops in Axiom. Before, the stop event went only to Analytics Engine.Verification
test/integration/container-idle.test.ts:main.typecheck,lintandoxfmtpass.mainand on this branch. The 2 new tests pass.MAX_RE_ESCALATIONS.Visual Changes
N/A
Reviewer Notes
cloudflare-logpush), the number of towns withcontainer.ready_observedshould drop to about the number of towns with working agents.stalledfor more than 30 minutes gets one cold start from the status poll. Then the agent comes backnot_found, becomes idle, and the container stops again.maybeDispatchTriageAgent: triage batch bead active or in cooldown) is a separate bug.