Skip to content

The agent that grows with you

refactor(delegate): drop process_command_fallback, keep the selected provider

Teknium5e8639accd20
diff --git a/providers/base.py b/providers/base.py
index 105b614cde3..f92135ba3e6 100644
--- a/providers/base.py
+++ b/providers/base.py
@@ -222,11 +222,6 @@ class ProviderProfile:
process_command_env_vars: tuple = () # env overrides for the binary, in priority order
process_args_env_var: str = "" # env override for argv (shlex-split)
- # ── L5: external-process (ACP) seams ──
- # Serves a pinned ``delegation.command`` whose binary no profile's process_command names (a
- # generic ACP stdio client); the first registered profile setting it wins.
- process_command_fallback: bool = False
-
# ── Model catalog ─────────────────────────────────────────
# fallback_models: curated list shown in /model picker when live fetch fails.
# Only agentic models that support tool calling should appear here.
diff --git a/tests/tools/test_delegate_external_provider.py b/tests/tools/test_delegate_external_provider.py
index 1add0f50135..a410a928cf9 100644
--- a/tests/tools/test_delegate_external_provider.py
+++ b/tests/tools/test_delegate_external_provider.py
@@ -1,4 +1,4 @@
-"""A selected external-process provider must survive child command resolution."""
+"""A pinned command keeps the provider whose runtime resolved it through child command resolution."""
import os
import sys
from types import SimpleNamespace
@@ -9,32 +9,6 @@ from providers.base import ProviderProfile
from tools.delegate_tool_config import _resolve_child_runtime
[email protected]("external", [True, False])
-def test_pinned_command_retains_selected_external_provider(external, process_profiles):
- profile = ProviderProfile(name="test-process-provider", display_name="Test", auth_type="external_process" if external else "api_key")
- fallback = ProviderProfile(name="fallback-acp", auth_type="external_process", process_command="agent-cli",
- process_command_fallback=True)
- process_profiles(profile, fallback)
- parent = SimpleNamespace(model="test-model", provider=profile.name, base_url="process://test", api_mode="chat_completions", acp_args=[])
- result = _resolve_child_runtime(
- parent, {}, "external-process", model=None, override_provider=profile.name,
- override_base_url=None, override_api_key=None, override_api_mode=None,
- override_acp_command=sys.executable, override_acp_args=[],
- )
- assert result["provider"] == (profile.name if external else fallback.name)
- assert result["requested_provider"] == result["provider"]
- assert result["acp_command"] == sys.executable
-
-
-def _resolve_pinned(command, provider="api-provider"):
- parent = SimpleNamespace(model="m", provider=provider, base_url="https://api.example/v1",
- api_mode="chat_completions", acp_args=[])
- return _resolve_child_runtime(
- parent, {}, "key", model=None, override_provider=provider, override_base_url=None, override_api_key=None,
- override_api_mode=None, override_acp_command=command, override_acp_args=[],
- )
-
-
@pytest.fixture
def process_profiles(monkeypatch):
"""Swap the provider registry the resolver reads for a fixed set of profiles."""
@@ -47,24 +21,21 @@ def process_profiles(monkeypatch):
return install
-def test_pinned_command_resolves_the_profile_that_launches_that_binary(process_profiles):
- binary = os.path.basename(sys.executable)
- process_profiles(
- ProviderProfile(name="api-provider", auth_type="api_key"),
- ProviderProfile(name="generic-acp", auth_type="external_process", process_command="agent-cli",
- process_command_fallback=True),
- ProviderProfile(name="harness-acp", auth_type="external_process", process_command=binary,
- api_mode="chat_completions"),
- )
- result = _resolve_pinned(sys.executable)
- assert (result["provider"], result["api_mode"], result["acp_command"]) == (
- "harness-acp", "chat_completions", sys.executable)
-
-
-def test_pinned_command_without_a_matching_or_fallback_profile_fails_loudly(process_profiles):
- process_profiles(
- ProviderProfile(name="api-provider", auth_type="api_key"),
- ProviderProfile(name="harness-acp", auth_type="external_process", process_command="some-other-cli"),
[email protected]("external", [True, False])
+def test_pinned_command_retains_the_selected_provider(external, process_profiles):
+ profile = ProviderProfile(name="test-process-provider", display_name="Test",
+ auth_type="external_process" if external else "api_key")
+ # Another installed external-process profile launching the very same binary must not capture the child.
+ same_binary = ProviderProfile(name="harness-acp", auth_type="external_process",
+ process_command=os.path.basename(sys.executable), api_mode="anthropic_messages")
+ process_profiles(profile, same_binary)
+ parent = SimpleNamespace(model="test-model", provider=profile.name, base_url="process://test",
+ api_mode="chat_completions", acp_args=[])
+ result = _resolve_child_runtime(
+ parent, {}, "external-process", model=None, override_provider=profile.name,
+ override_base_url=None, override_api_key=None, override_api_mode="chat_completions",
+ override_acp_command=sys.executable, override_acp_args=[],
)
- with pytest.raises(ValueError, match="does not belong to any installed external-process provider"):
- _resolve_pinned(sys.executable)
+ assert (result["provider"], result["api_mode"]) == (profile.name, "chat_completions")
+ assert result["requested_provider"] == result["provider"]
+ assert result["acp_command"] == sys.executable
diff --git a/tools/delegate_tool_config.py b/tools/delegate_tool_config.py
index f3bc6c3637b..23b175f937b 100644
--- a/tools/delegate_tool_config.py
+++ b/tools/delegate_tool_config.py
@@ -327,35 +327,6 @@ def _require_pinned_command(command: Optional[str], message: str) -> None:
if command and not _shutil.which(command):
raise ValueError(message)
-def _process_command_provider(
- command: str, provider: Optional[str], api_mode: Optional[str],
-) -> tuple[str, Optional[str]]:
- """(provider, api_mode) that runs a pinned ``delegation.command``: the selected provider when it is
- already an external-process one; else the external-process profile whose ``process_command`` names the
- same binary; else the profile flagged ``process_command_fallback``. No candidate fails the spawn."""
- from providers import get_provider_profile, list_providers
-
- selected = get_provider_profile(provider or "")
- if selected is not None and selected.auth_type == "external_process":
- return provider, api_mode
- candidates = [p for p in list_providers() if p.auth_type == "external_process"]
- binary = _command_stem(command)
- match = next((p for p in candidates if p.process_command and _command_stem(p.process_command) == binary), None)
- match = match or next((p for p in candidates if p.process_command_fallback), None)
- if match is None:
- raise ValueError(
- f"Pinned delegation command '{command}' does not belong to any installed external-process provider. "
- "Install the provider plugin for it, or remove delegation.command from config.yaml.")
- return match.name, match.api_mode or "chat_completions"
-
-
-def _command_stem(command: str) -> str:
- """Binary name of ``command`` without directory or a Windows launcher suffix (``kimchi.cmd`` -> ``kimchi``)."""
- name = os.path.basename(command.strip().replace("\\", "/")).lower()
- stem, ext = os.path.splitext(name)
- return stem if ext in {".exe", ".cmd", ".bat", ".ps1"} else name
-
-
def _credential_bundle(model, provider, base_url, api_key, api_mode, request_overrides, **extra) -> dict:
"""The child credential dict every branch of ``_resolve_delegation_credentials`` returns."""
return {
@@ -604,13 +575,8 @@ def _resolve_child_runtime(
# ACP client and bypass the override credentials entirely (issue #16816).
if override_provider and not override_acp_command:
effective_acp_command, effective_acp_args = None, []
- # Defensive: validate trusted delegation.command exists on PATH before honoring it. An explicitly pinned
- # transport that cannot run must fail the spawn loudly (#80450) — silently falling back to the default
- # transport would run the child somewhere the user explicitly routed it away from. Normally unreachable
- # via delegate_task, which pre-validates the command in _resolve_delegation_credentials.
- if override_acp_command:
- effective_provider, effective_api_mode = _process_command_provider(
- override_acp_command, effective_provider, effective_api_mode)
+ # A pinned command arrives only with the runtime of the provider that resolved it, so the selected
+ # provider (and its api_mode) is kept as is.
# A named provider identity is endpoint-scoped. Preserve it only when the
# child inherits the exact parent route; an override owns its final identity.
diff --git a/website/docs/developer-guide/model-provider-plugin.md b/website/docs/developer-guide/model-provider-plugin.md
index f58546a3cc4..0a34fe38e73 100644
--- a/website/docs/developer-guide/model-provider-plugin.md
+++ b/website/docs/developer-guide/model-provider-plugin.md
@@ -254,7 +254,6 @@ meaning says otherwise.
| `process_args` | External-process default argv tail | `()` |
| `process_command_env_vars` | Env vars overriding the binary, in priority order | `()` |
| `process_args_env_var` | Env var overriding argv (shlex-split) | `""` |
-| `process_command_fallback` | Serves a pinned `delegation.command` no profile's `process_command` names; first registered wins | `False` |
| `fallback_models` | Curated picker list when the live fetch fails | `()` |
| `model_aliases` | Short name → model id; `/model <alias>` resolves here first | `{}` |
| `hostname` | Base hostname for URL → provider reverse mapping (derived from `base_url` when empty) | `""` |
@@ -373,11 +372,10 @@ An agent CLI driven over stdio is not an HTTP endpoint. Set `auth_type="external
| Field | Purpose |
|---|---|
-| `process_command` | Default binary, e.g. `"kimchi"`. A pinned `delegation.command` naming the same binary runs on this provider |
+| `process_command` | Default binary, e.g. `"kimchi"` |
| `process_args` | Default argv tail, e.g. `("--mode", "acp")` |
| `process_command_env_vars` | Env vars that override the binary, checked in order |
| `process_args_env_var` | Env var that overrides argv (shlex-split) |
-| `process_command_fallback` | `True` makes this provider run a pinned `delegation.command` no profile's `process_command` names (default `False`; first registered wins, none = the spawn fails) |
The `process_command_env_vars` and `process_args_env_var` names are executable authority: Hermes' generic env writers (dashboard, MCP and connector installs, `save_env_value`) refuse them, so set them in `.env` or the shell.