fix(delegate): guard child credential pool binding - #35499
Closed
JabberELF wants to merge 1 commit into
Closed
Conversation
7 tasks
Contributor
Author
|
Closing — upstream main already implements this via in (line 2371). Child credential pool binding is guarded with at both assignment (line 1187) and lease acquisition (line 1395). This PR is now redundant. |
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
This PR hardens
delegate_taskcredential-pool handling so a child agent does not bind a leased credential from a different provider/runtime endpoint.It adds two guards:
_run_single_child()now verifies the leased credential matches the child runtime before calling_swap_credential()._resolve_child_credential_pool()no longer blindly shares the parent's pool when the parent pool carries explicit provider metadata that differs from the child provider. It falls back to loading the child provider's own pool instead.This preserves the existing compatibility behavior for old/test pool objects that lack provider metadata, and keeps
custom:<name>compatible with the bare configured custom-provider name.Why
The existing delegation path can accidentally combine a child runtime from one provider with a leased credential/base URL from another provider. One observed shape is an
openai-codexchild using the Codex model/runtime while swapping to a Xiaomi OpenAI-compatible endpoint from the credential pool, producing HTTP 404s.Related but different prior work:
api_modeinheritance.This PR focuses specifically on the credential-pool lease/swap contamination path.
Tests
Results:
py_compile: passed12 passedtests/tools/test_delegate.py:137 passedgit diff --check: passedThe only warning seen locally is the pre-existing
discord.player/audioopPython 3.13 deprecation warning.