From 6c115440fde09215745f60b3f9729f044c7d4a5d Mon Sep 17 00:00:00 2001 From: Tranquil-Flow Date: Fri, 10 Apr 2026 13:14:35 +1000 Subject: [PATCH] fix(delegate): sync self.base_url with client_kwargs after credential resolution MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 #6825 --- run_agent.py | 1 + 1 file changed, 1 insertion(+) diff --git a/run_agent.py b/run_agent.py index fc7f72b731b..df49987fee1 100644 --- a/run_agent.py +++ b/run_agent.py @@ -947,6 +947,7 @@ class AIAgent: client_kwargs["default_headers"] = headers self.api_key = client_kwargs.get("api_key", "") + self.base_url = client_kwargs.get("base_url", self.base_url) try: self.client = self._create_openai_client(client_kwargs, reason="agent_init", shared=True) if not self.quiet_mode: