From 7dbde8e85d9c57f526e129d620a7c7a0cb7b1026 Mon Sep 17 00:00:00 2001 From: jenkins Date: Sat, 15 Aug 2026 13:28:47 -0300 Subject: [PATCH] hermes: adaptively scale engineering routes --- services/hermes/agent-configmap.yaml | 6 +++--- .../hermes/plugins/auto-router/__init__.py | 10 ++++++++- services/hermes/switchyard-deployment.yaml | 2 +- testing/tests/test_hermes_auto_router.py | 21 ++++++++++++++++++- testing/tests/test_hermes_cli_lanes.py | 5 +++++ 5 files changed, 38 insertions(+), 6 deletions(-) diff --git a/services/hermes/agent-configmap.yaml b/services/hermes/agent-configmap.yaml index a5281bf5..ac7c3a9b 100644 --- a/services/hermes/agent-configmap.yaml +++ b/services/hermes/agent-configmap.yaml @@ -10,15 +10,15 @@ data: config.yaml: | model: provider: atlas-switchyard - default: atlas/auto/maximum - model: atlas/auto/maximum + default: atlas/auto/balanced + model: atlas/auto/balanced providers: atlas-switchyard: name: Atlas Switchyard api: http://hermes-switchyard.hermes.svc.cluster.local:9005/v1 api_key: atlas-switchyard - default_model: atlas/auto/maximum + default_model: atlas/auto/balanced transport: chat_completions fallback_providers: [] diff --git a/services/hermes/plugins/auto-router/__init__.py b/services/hermes/plugins/auto-router/__init__.py index b79c4fb4..f962e876 100644 --- a/services/hermes/plugins/auto-router/__init__.py +++ b/services/hermes/plugins/auto-router/__init__.py @@ -15,6 +15,7 @@ except ImportError: # Direct module loading in the small unit-test harness. POLICY_PATH = Path("/opt/data/workspace/coordinator/route-policy.json") +POLICY_VERSION = 2 SWITCHYARD_PROVIDER = "atlas-switchyard" ROUTER_PROFILE = os.environ.get("HERMES_AUTO_ROUTER_PROFILE", "").strip().lower() if ROUTER_PROFILE not in {"chat", "triage", "agent"}: @@ -27,7 +28,7 @@ if ROUTER_PROFILE not in {"chat", "triage", "agent"}: PROFILE_ROUTE = { "chat": "atlas/auto/fast", "triage": "atlas/auto/deep", - "agent": "atlas/auto/maximum", + "agent": "atlas/auto/balanced", } PRIORITY_ROUTE = { "fast": "atlas/auto/fast", @@ -65,6 +66,12 @@ def _load_policy() -> dict[str, Any]: value = {} if not isinstance(value, dict): value = {} + if value.get("version") != POLICY_VERSION: + value = { + "version": POLICY_VERSION, + "mode": "auto", + "auto_route": PROFILE_ROUTE[ROUTER_PROFILE], + } if value.get("mode") not in {"auto", "manual"}: value["mode"] = "auto" route = str(value.get("auto_route") or "") @@ -75,6 +82,7 @@ def _load_policy() -> dict[str, Any]: def _write_policy(value: dict[str, Any]) -> None: """Persist route preference atomically inside the current workspace.""" + value["version"] = POLICY_VERSION POLICY_PATH.parent.mkdir(parents=True, exist_ok=True) temporary = POLICY_PATH.with_suffix(".json.tmp") temporary.write_text( diff --git a/services/hermes/switchyard-deployment.yaml b/services/hermes/switchyard-deployment.yaml index ac353fd6..10afe67b 100644 --- a/services/hermes/switchyard-deployment.yaml +++ b/services/hermes/switchyard-deployment.yaml @@ -22,7 +22,7 @@ spec: labels: app: hermes-switchyard annotations: - ai.bstein.dev/config-rev: "20260815-maximum-high-floor" + ai.bstein.dev/config-rev: "20260815-quality-escalation" prometheus.io/scrape: "true" prometheus.io/port: "9005" prometheus.io/path: /metrics diff --git a/testing/tests/test_hermes_auto_router.py b/testing/tests/test_hermes_auto_router.py index f801230b..fd8d8606 100644 --- a/testing/tests/test_hermes_auto_router.py +++ b/testing/tests/test_hermes_auto_router.py @@ -43,7 +43,7 @@ def test_profile_defaults_are_distinct_and_quality_ordered(): assert router.PROFILE_ROUTE == { "chat": "atlas/auto/fast", "triage": "atlas/auto/deep", - "agent": "atlas/auto/maximum", + "agent": "atlas/auto/balanced", } assert router.PROFILE_ROUTE[router.ROUTER_PROFILE] in router.AUTO_ROUTES @@ -59,6 +59,25 @@ def test_auto_boundary_selects_only_a_public_switchyard_route(tmp_path, monkeypa assert source == "auto" +def test_legacy_maximum_default_migrates_to_adaptive_agent_route( + tmp_path, monkeypatch +): + path = tmp_path / "route-policy.json" + path.write_text( + json.dumps({"mode": "auto", "auto_route": "atlas/auto/maximum"}), + encoding="utf-8", + ) + monkeypatch.setattr(router, "POLICY_PATH", path) + + policy = router._load_policy() + + assert policy == { + "version": router.POLICY_VERSION, + "mode": "auto", + "auto_route": router.PROFILE_ROUTE[router.ROUTER_PROFILE], + } + + def test_ui_priority_changes_auto_posture_without_selecting_a_target( tmp_path, monkeypatch ): diff --git a/testing/tests/test_hermes_cli_lanes.py b/testing/tests/test_hermes_cli_lanes.py index e82fd874..ac6b8bb8 100644 --- a/testing/tests/test_hermes_cli_lanes.py +++ b/testing/tests/test_hermes_cli_lanes.py @@ -658,6 +658,11 @@ def test_legacy_state_is_archived_without_removing_provider_transcripts(tmp_path def test_agent_uses_one_native_kanban_control_plane(): configmap = yaml.safe_load((HERMES / "agent-configmap.yaml").read_text()) config = yaml.safe_load(configmap["data"]["config.yaml"]) + assert config["model"] == { + "provider": "atlas-switchyard", + "default": "atlas/auto/balanced", + "model": "atlas/auto/balanced", + } assert config["kanban"]["dispatch_in_gateway"] is True assert config["kanban"]["default_assignee"] == "cli-auto" assert config["plugins"]["enabled"] == ["auto-router"]