From 5d0947434864811d46af0cce09cdf5e842f51e5d Mon Sep 17 00:00:00 2001 From: TaroballzChen Date: Sun, 12 Apr 2026 16:25:56 +0800 Subject: [PATCH] fix(tools): enforce ACP transport overrides in delegate_task child agents When override_acp_command was passed to _build_child_agent, it failed to override effective_provider to 'copilot-acp' and effective_api_mode to 'chat_completions'. This caused the child AIAgent to inherit the parent's native API configuration (e.g. Anthropic) and attempt real HTTP requests using the parent's API key, leading to HTTP 401 errors and completely bypassing the ACP subprocess. Ensure that if an ACP command override is provided, the child agent correctly routes through CopilotACPClient. Refs #2653 --- tools/delegate_tool.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/delegate_tool.py b/tools/delegate_tool.py index 19a9916da..7b0179c4c 100644 --- a/tools/delegate_tool.py +++ b/tools/delegate_tool.py @@ -922,6 +922,12 @@ def _build_child_agent( else (getattr(parent_agent, "acp_args", []) or []) ) + if override_acp_command: + # If explicitly forcing an ACP transport override, the provider MUST be copilot-acp + # so run_agent.py initializes the CopilotACPClient. + effective_provider = "copilot-acp" + effective_api_mode = "chat_completions" + # Resolve reasoning config: delegation override > parent inherit parent_reasoning = getattr(parent_agent, "reasoning_config", None) child_reasoning = parent_reasoning