fix(delegate): inherit parent api_key when delegation.base_url set without delegation.api_key#19741
Merged
Conversation
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
4 tasks
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.
Salvage of #15853 by @briandevans onto current main.
Summary
When
delegation.base_urlis configured withoutdelegation.api_key, the child agent was falling back toOPENAI_API_KEYfrom the env instead of inheriting the parent's resolved key. Parents running on non-OpenAI providers (Anthropic, Kimi, MiniMax, DashScope) saw their children fail auth because the inherited key was the wrong one.Return
api_key=Nonefrom_resolve_delegation_credentialswhen not configured, so_build_child_agentuseseffective_api_key = override_api_key or parent_api_key— the parent's key, with explicit override still respected.Conflict resolution during salvage
Main's docstring was updated for the related provider-resolution path since the PR opened. Merged docstrings so both code paths are documented. Updated two existing tests that locked in the old OPENAI_API_KEY-fallback behavior to expect the new inheritance semantics.
Changes
Validation
scripts/run_tests.sh tests/tools/test_delegate.py -k direct_endpoint -> 4 passed
Original PR: #15853
Fixes: #15810