fix(credential_pool): sync provider endpoints from auth state - #21413
Closed
DanielLSM wants to merge 1 commit into
Closed
fix(credential_pool): sync provider endpoints from auth state#21413DanielLSM wants to merge 1 commit into
DanielLSM wants to merge 1 commit into
Conversation
DanielLSM
force-pushed
the
fix/provider-endpoint-sync-and-commands
branch
2 times, most recently
from
May 7, 2026 16:34
df5af44 to
fbd7628
Compare
## Problem When a provider has multiple API surfaces (e.g. Z.AI regular vs coding-plan endpoints), the pool entry's base_url can become stale after runtime endpoint detection finds a different working URL. The entry stays exhausted on the wrong endpoint indefinitely, even though auth.json contains the correct detected endpoint. ## Changes ### agent/credential_pool.py - Add _sync_endpoint_from_provider_state(): generalized method that checks provider_state.<provider>.detected_endpoint in auth.json and adopts a newer endpoint when the cached base_url differs from the pool entry. Clears exhaustion immediately so the entry can be retried. - Re-probe on cooldown expiry: after clear_expired resets an exhausted entry, call the provider's endpoint detection to verify the cached base_url is still valid. If the endpoint changed, update it. If no endpoint works, keep the entry exhausted and preserve the original error context. - The sync pattern is provider-agnostic (currently enabled for zai; extensible to any provider that caches detected_endpoint in provider_state). ## Related Issues - Fixes credential pool exhaustion causing wrong endpoint fallback (pattern similar to NousResearch#5668 transient-auth cooldown issues and NousResearch#19083 custom-provider key mix-ups). ## Test Plan python -m pytest tests/agent/test_credential_pool.py -q All tests pass.
DanielLSM
force-pushed
the
fix/provider-endpoint-sync-and-commands
branch
from
May 7, 2026 16:34
fbd7628 to
cfa6b9e
Compare
Contributor
Author
|
Closing to reopen with clean commit history. |
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
When a provider has multiple API surfaces (e.g. Z.AI regular vs coding-plan endpoints), the pool entry's base_url can become stale after runtime endpoint detection finds a different working URL. The entry stays exhausted on the wrong endpoint indefinitely, even though auth.json contains the correct detected endpoint.
Changes
agent/credential_pool.py
_sync_endpoint_from_provider_state(): generalized method that checksprovider_state.<provider>.detected_endpointin auth.json and adopts a newer endpoint when the cached base_url differs from the pool entry. Clears exhaustion immediately so the entry can be retried.clear_expiredresets an exhausted entry, call the provider's endpoint detection to verify the cached base_url is still valid. If the endpoint changed, update it. If no endpoint works, keep the entry exhausted and preserve the original error context.detected_endpointinprovider_state).Related Issues
Test Plan
All tests pass.