fix(delegation): prevent credential pool from overriding explicit delegation.base_url - #61258
Conversation
…egation.base_url (NousResearch#61195) When delegation.base_url is explicitly configured, the child agent's base_url, provider, and api_mode are correctly resolved to the delegation values throughout init_agent(). However, the credential pool leasing in _run_single_child() could later call _swap_credential(), which overwrites self.base_url (and self._client_kwargs['base_url']) with values from the pool entry — potentially restoring the parent agent's OpenRouter endpoint and causing 401 authentication failures. Fix: skip credential pool assignment when override_base_url is set from the delegation config, ensuring the explicitly configured endpoint is always honored.
Duplicate of #13752 (earliest open PR for this fix). Both skip the child credential-pool binding when |
|
Thanks for tracing the credential-pool lease path. This is an automated hermes-sweeper review; current
The proposed unconditional skip would also remove valid child-provider credential rotation for every explicit direct endpoint. |
Description
Fixes #61195
When
delegation.base_urlis explicitly configured (e.g.https://api.anthropic.com) while the primary model uses a different provider (e.g.openrouter), the subagent'sagent.base_url,agent.provider, andagent.api_modeare correctly resolved to the delegation values throughoutinit_agent(). However, the credential pool leasing in_run_single_child()could later call_swap_credential(), which overwritesself.base_url(andself._client_kwargs['base_url']) with values from the pool entry — potentially restoring the parent agent's OpenRouter endpoint and causing 401 authentication failures.Fix
Skip credential pool assignment in
_build_child_agent()whenoverride_base_urlis set from the delegation config (delegation.base_url). This ensures the explicitly configured endpoint is always honored and never overwritten by a stale pool entry.Rationale
When the user explicitly configures
delegation.base_url, they are directing subagents to a specific endpoint. A credential pool that was loaded for the same provider name (e.g.anthropic) may contain entries with a differentruntime_base_urlthan the one configured indelegation.base_url, because the pool was set up for a different use case (e.g. rate-limiting rotation on the parent's provider).The credential pool is still available for subagents that inherit the parent's provider (where
override_base_urlis not set), preserving the rate-limit rotation feature for the default case.Test Plan
pytest tests/tools/test_delegate.py -vpytest tests/tools/test_async_delegation.py -v