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
This commit is contained in:
TaroballzChen 2026-04-12 16:25:56 +08:00 committed by Teknium
parent 33773ed5c6
commit 5d09474348

View file

@ -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