feat(pools): pool exhaustion handling + opt-in agent auth auto-reset#49
Merged
Conversation
…e exhausted notice dedup (A1)
…AgentProfile.ExecUser
… field, document 204
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.
Problem
Live, both members of
openai_poolhit the OpenAI Codex usage-limit 429 (a multi-hour quota window). sluice cooled each member for a flat 60s, then the all-cooling degrade path re-served the soonest-recovering member, which 429'd again. That produced a perpetualopenai_oauthtoopenai_oauth_2failover flap and roughly 2 Telegram notices per minute, forever. The sticky-failover fix (#48) stopped the snap-to-position-0 flap but left this degrade-path flap in place.Second problem: when the whole pool is exhausted the agent can latch "usage limit reached" and stop, needing a manual
hermes auth resetto resume.What this does
Three fixes for the flap plus an opt-in auto-reset.
Retry-After/x-ratelimit-reset*headers (clamped 10s to 6h) instead of a flat 60s, so a quota-exhausted member stays cooled for the real window and is not re-probed every 60s.auth_reset_targetcolumn on the pool. When it is set and the pool recovers, sluice runs the agent auth-reset command (hermes profile, executed as uid 10000:10000 to avoid root-chowning auth.json) so the agent un-latches. An empty target means no reset, so this is off by default.auth_reset_targetis reachable from CLI, REST, and Telegram through the channel-agnosticinternal/poolops, per the channel parity rule.Notes for review
auth_reset_targetunset to get the flap and spam fix without sluice ever touching the agent.000008_pool_auth_resetadds the column. Its down migration snapshots the FK-tied member rows before the table rebuild so the cascade does not drop them.Testing
go test ./...passes across all 14 packages,-raceclean on the touched packages, gofumpt andgo vet ./...clean, andmake generateproduces no diff. New unit tests cover the cooldown header parsing and clamp, exhaustion detection, the recovery monitor edges (unequal cooldowns, pool removed while exhausted, clean shutdown), the auth-reset argv and uid, validation parity across all channels, and migration 000008 up and down on a populated table.Plan:
docs/plans/completed/20260522-pool-exhaustion-and-agent-auth-reset.md