fix(agent): check credential pool exhaustion before restoring primary runtime (#15298)#15434
Open
Tranquil-Flow wants to merge 2 commits into
Open
Conversation
5 tasks
7ac0646 to
8c75dd0
Compare
… runtime (NousResearch#15298) After the 60-second rate-limit timer expires, restore_primary_runtime() attempted to restore the primary provider every turn even if the credential pool still marked all credentials as exhausted. This burned retries and generated noise during extended outages. Now, after the _rate_limited_until check, if the agent has a _credential_pool for the primary provider and the pool reports no available credentials (all exhausted), restoration is skipped. This integrates with the existing credential pool architecture (has_available / _mark_exhausted) rather than adding another independent timer. Adapted from the original PR: main has refactored _restore_primary_runtime into agent.agent_runtime_helpers.restore_primary_runtime; the gate now lives in the helper. Tests reach the helper transparently through the forwarder on AIAgent.
8c75dd0 to
287fccd
Compare
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.
What does this PR do?
_restore_primary_runtime()checks a 60-second rate-limit timer (_rate_limited_until) but does not consult the credential pool's exhaustion state. After the 60-second timer expires, it attempts to restore the primary provider every turn even if the credential pool still marks that provider as exhausted. This burns retries and generates noise during extended outages.Related Issue
Fixes #15298
Type of Change
Changes Made
run_agent.py— after the_rate_limited_untilcheck in_restore_primary_runtime(), added a guard that consultsself._credential_pool.has_available(). If the pool exists for the primary provider and reports all credentials exhausted, restoration is skipped. This integrates with the existingCredentialPoolarchitecture (which already tracks per-credential exhaustion with cooldowns) rather than adding another independent timer.tests/run_agent/test_primary_runtime_restore.py— 4 new tests inTestCredentialPoolExhaustionGateHow to Test
pytest tests/run_agent/test_primary_runtime_restore.py::TestCredentialPoolExhaustionGate -v— 4 new tests cover:Checklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AScreenshots / Logs
N/A — see commit description and PR diff.