mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-19 13:28:58 +03:00
5e8639accd
R4 review ACP-3: ProviderProfile.process_command_fallback and _process_command_provider served a "pinned delegation.command" that no config key produces. override_acp_command only comes from creds["command"], i.e. the runtime of the external-process provider that resolved it, so the selected provider was always kept at the first branch; the binary-stem match and the fallback flag were reachable only from direct unit calls. Remove the field, the stem matching and their developer-guide rows. A pinned command now always keeps the selected provider and api_mode (base rerouted non-external selections to the hard-coded copilot-acp slug; a same-binary profile no longer captures the child either). probe_deleg: delegation.provider kimchi-acp / kimchi-agent still resolve to kimchi-acp, as on base. The labs plugin's process_command_fallback=True must go too.
42 lines
2.0 KiB
Python
42 lines
2.0 KiB
Python
"""A pinned command keeps the provider whose runtime resolved it through child command resolution."""
|
|
import os
|
|
import sys
|
|
from types import SimpleNamespace
|
|
|
|
import pytest
|
|
|
|
from providers.base import ProviderProfile
|
|
from tools.delegate_tool_config import _resolve_child_runtime
|
|
|
|
|
|
@pytest.fixture
|
|
def process_profiles(monkeypatch):
|
|
"""Swap the provider registry the resolver reads for a fixed set of profiles."""
|
|
import providers
|
|
|
|
def install(*profiles):
|
|
by_name = {p.name: p for p in profiles}
|
|
monkeypatch.setattr(providers, "get_provider_profile", by_name.get)
|
|
monkeypatch.setattr(providers, "list_providers", lambda: list(profiles))
|
|
return install
|
|
|
|
|
|
@pytest.mark.parametrize("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=[],
|
|
)
|
|
assert (result["provider"], result["api_mode"]) == (profile.name, "chat_completions")
|
|
assert result["requested_provider"] == result["provider"]
|
|
assert result["acp_command"] == sys.executable
|