Without a delegation override the child took base_url from the parent's live client (_client_kwargs / client.base_url) but api_key from the surface attribute parent_agent.api_key. After a fallback or any runtime swap the surface key can lag the live client, so the child was built with a (base_url, key) pair that was never valid on the parent and died on an instant, non-retryable 401 (#90009, reporter's log shape). _inherit_parent_base_url becomes _inherit_parent_endpoint and returns the (base_url, api_key) pair from one source: the live client kwargs when the parent has an OpenAI-wire client, the surface attributes otherwise (native Anthropic/Bedrock runtimes keep client=None). The override branches keep the salvaged all-or-nothing rule from #111823. Live probe (real AIAgent, real try_activate_fallback, two fake servers): before, a parent on fallback B with a lagging surface key sent `Bearer FAKE-KEY-PRIMARY-A` to server B from the child; after, the child sends B's key to B. Natural fallback (no lag) is unchanged. Tests trimmed to three invariants (override never borrows the parent endpoint, provider without base_url is refused, no-override inherits live endpoint+key together); all red on origin/main. Fixes #90009 Salvages #111823
2 lines
7 B
Plaintext
2 lines
7 B
Plaintext
lucvan
|