Skip to content

The agent that grows with you

fix(delegation): a profile pinned to a missing ACP command refuses at routing

Teknium9add231d9df4
diff --git a/tests/tools/test_delegation_profile_route.py b/tests/tools/test_delegation_profile_route.py
index e2862ddf417..122cacfeab0 100644
--- a/tests/tools/test_delegation_profile_route.py
+++ b/tests/tools/test_delegation_profile_route.py
@@ -291,3 +291,18 @@ def test_profile_route_is_refused_under_a_managed_worker_config_snapshot(two_pro
assert routes == [] and "managed worker" in (error or "")
with pytest.raises(DelegationRouteError):
_route_to_task_route({"profile": "coder"}, _parent(), {})
+
+
+def test_profile_pinned_to_a_missing_acp_command_is_refused_at_routing(two_profiles, monkeypatch):
+ """Same rule as ``delegation.provider`` (#80450): a profile whose provider is pinned to an ACP binary
+ that is not on PATH refuses the spawn, naming the profile, instead of building a broken child."""
+ _, coder = two_profiles
+ _set_config(coder, model={"provider": "copilot-acp", "default": "coder-model"})
+ # An acp+tcp endpoint keeps the configured command unresolved (the runtime resolver only refuses a missing
+ # binary when it would spawn one); the delegation pin rule still refuses it.
+ monkeypatch.setenv("HERMES_COPILOT_ACP_COMMAND", "hermes-test-missing-acp-binary")
+ monkeypatch.setenv("COPILOT_ACP_BASE_URL", "acp+tcp://127.0.0.1:9")
+
+ routes, error = _resolve_coder_task()
+ assert routes == []
+ assert "hermes-test-missing-acp-binary" in (error or "") and "coder" in error
diff --git a/tools/delegate_tool_routes.py b/tools/delegate_tool_routes.py
index bb5f56684bf..42df7e76da8 100644
--- a/tools/delegate_tool_routes.py
+++ b/tools/delegate_tool_routes.py
@@ -179,7 +179,7 @@ def _profile_route(home: Path, label: Optional[str]) -> TaskRoute:
from hermes_cli.config import load_config_readonly
from hermes_cli.runtime_provider import resolve_runtime_provider
from hermes_constants import resolve_reasoning_config
- from tools.delegate_tool_config import ResolvedReasoning, _credential_bundle
+ from tools.delegate_tool_config import ResolvedReasoning, _credential_bundle, _require_pinned_command
_refuse_under_worker_snapshot(home)
with delegated_profile_scope(home):
cfg = load_config_readonly() or {}
@@ -194,6 +194,10 @@ def _profile_route(home: Path, label: Optional[str]) -> TaskRoute:
# does) so two named providers sharing one URL never lease each other's pool.
requested = str(rt.get("requested_provider") or "").strip()
provider = requested if rt.get("provider") == "custom" and requested.lower() not in ("", "auto") else rt.get("provider")
+ # Same rule as delegation.provider (#80450): a pinned ACP command that is not on PATH refuses the spawn.
+ _require_pinned_command(
+ rt.get("command"), f"Profile at {home} is pinned to the '{rt.get('command')}' command, which was not "
+ f"found on PATH. Install it or route this task elsewhere.")
creds = _credential_bundle(
model, provider, rt.get("base_url"),
rt.get("api_key") or "no-key-required", rt.get("api_mode"), dict(rt.get("request_overrides") or {}),