fix(delegate): sync self.base_url with client_kwargs after credential resolution - #6933
Closed
Tranquil-Flow wants to merge 1 commit into
Closed
Conversation
… resolution When delegation.base_url routes subagents to a different endpoint, the correct URL was passed through _resolve_delegation_credentials() and _build_child_agent() into AIAgent.__init__(), but self.base_url could fall out of sync with client_kwargs["base_url"] — the value the OpenAI client actually uses. This caused billing_base_url in session records to show the parent's endpoint while actual API calls went to the correct delegation target. Keep self.base_url in sync with client_kwargs after the credential resolution block, matching the existing pattern for self.api_key. Fixes NousResearch#6825
Tranquil-Flow
force-pushed
the
fix/delegation-base-url-overwrite
branch
from
April 10, 2026 13:51
fa0ae78 to
30b7476
Compare
Contributor
|
Merged via PR #7360. Cherry-picked with authorship preserved. Textbook one-liner — thanks! |
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
Fixes #6825
When
delegation.base_urlroutes subagents to a different endpoint, the correct URL is passed through_resolve_delegation_credentials()and_build_child_agent()intoAIAgent.__init__(), butself.base_urlcan fall out of sync withclient_kwargs["base_url"]— the value the OpenAI client actually uses.This causes
billing_base_urlin session records to show the parent's endpoint while actual API calls go to the correct delegation target.Root cause
At
run_agent.py:852,self.api_keyis synced fromclient_kwargsafter credential resolution, butself.base_url(set earlier at line 584) is never updated to match. When theelsebranch at line 797 resolves credentials viaresolve_provider_client(), the resolvedbase_urlgoes intoclient_kwargsbutself.base_urlstays stale.Fix
One-line addition after line 852 —
self.base_url = client_kwargs.get("base_url", self.base_url)— mirrors the existingself.api_keysync pattern. This also ensures the_primary_runtimesnapshot (line 1241) captures the correct base_url for fallback recovery.Test plan
test_delegate.py,test_delegate_toolset_scope.py,test_agent_loop.py):8001, delegation target on:8000— child sessionbilling_base_urlshould show:8000Platform
Tested on macOS (Darwin 24.6.0), Python 3.14.2