hermes: adaptively scale engineering routes
This commit is contained in:
parent
2ae88973be
commit
7dbde8e85d
@ -10,15 +10,15 @@ data:
|
|||||||
config.yaml: |
|
config.yaml: |
|
||||||
model:
|
model:
|
||||||
provider: atlas-switchyard
|
provider: atlas-switchyard
|
||||||
default: atlas/auto/maximum
|
default: atlas/auto/balanced
|
||||||
model: atlas/auto/maximum
|
model: atlas/auto/balanced
|
||||||
|
|
||||||
providers:
|
providers:
|
||||||
atlas-switchyard:
|
atlas-switchyard:
|
||||||
name: Atlas Switchyard
|
name: Atlas Switchyard
|
||||||
api: http://hermes-switchyard.hermes.svc.cluster.local:9005/v1
|
api: http://hermes-switchyard.hermes.svc.cluster.local:9005/v1
|
||||||
api_key: atlas-switchyard
|
api_key: atlas-switchyard
|
||||||
default_model: atlas/auto/maximum
|
default_model: atlas/auto/balanced
|
||||||
transport: chat_completions
|
transport: chat_completions
|
||||||
|
|
||||||
fallback_providers: []
|
fallback_providers: []
|
||||||
|
|||||||
@ -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_PATH = Path("/opt/data/workspace/coordinator/route-policy.json")
|
||||||
|
POLICY_VERSION = 2
|
||||||
SWITCHYARD_PROVIDER = "atlas-switchyard"
|
SWITCHYARD_PROVIDER = "atlas-switchyard"
|
||||||
ROUTER_PROFILE = os.environ.get("HERMES_AUTO_ROUTER_PROFILE", "").strip().lower()
|
ROUTER_PROFILE = os.environ.get("HERMES_AUTO_ROUTER_PROFILE", "").strip().lower()
|
||||||
if ROUTER_PROFILE not in {"chat", "triage", "agent"}:
|
if ROUTER_PROFILE not in {"chat", "triage", "agent"}:
|
||||||
@ -27,7 +28,7 @@ if ROUTER_PROFILE not in {"chat", "triage", "agent"}:
|
|||||||
PROFILE_ROUTE = {
|
PROFILE_ROUTE = {
|
||||||
"chat": "atlas/auto/fast",
|
"chat": "atlas/auto/fast",
|
||||||
"triage": "atlas/auto/deep",
|
"triage": "atlas/auto/deep",
|
||||||
"agent": "atlas/auto/maximum",
|
"agent": "atlas/auto/balanced",
|
||||||
}
|
}
|
||||||
PRIORITY_ROUTE = {
|
PRIORITY_ROUTE = {
|
||||||
"fast": "atlas/auto/fast",
|
"fast": "atlas/auto/fast",
|
||||||
@ -65,6 +66,12 @@ def _load_policy() -> dict[str, Any]:
|
|||||||
value = {}
|
value = {}
|
||||||
if not isinstance(value, dict):
|
if not isinstance(value, dict):
|
||||||
value = {}
|
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"}:
|
if value.get("mode") not in {"auto", "manual"}:
|
||||||
value["mode"] = "auto"
|
value["mode"] = "auto"
|
||||||
route = str(value.get("auto_route") or "")
|
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:
|
def _write_policy(value: dict[str, Any]) -> None:
|
||||||
"""Persist route preference atomically inside the current workspace."""
|
"""Persist route preference atomically inside the current workspace."""
|
||||||
|
value["version"] = POLICY_VERSION
|
||||||
POLICY_PATH.parent.mkdir(parents=True, exist_ok=True)
|
POLICY_PATH.parent.mkdir(parents=True, exist_ok=True)
|
||||||
temporary = POLICY_PATH.with_suffix(".json.tmp")
|
temporary = POLICY_PATH.with_suffix(".json.tmp")
|
||||||
temporary.write_text(
|
temporary.write_text(
|
||||||
|
|||||||
@ -22,7 +22,7 @@ spec:
|
|||||||
labels:
|
labels:
|
||||||
app: hermes-switchyard
|
app: hermes-switchyard
|
||||||
annotations:
|
annotations:
|
||||||
ai.bstein.dev/config-rev: "20260815-maximum-high-floor"
|
ai.bstein.dev/config-rev: "20260815-quality-escalation"
|
||||||
prometheus.io/scrape: "true"
|
prometheus.io/scrape: "true"
|
||||||
prometheus.io/port: "9005"
|
prometheus.io/port: "9005"
|
||||||
prometheus.io/path: /metrics
|
prometheus.io/path: /metrics
|
||||||
|
|||||||
@ -43,7 +43,7 @@ def test_profile_defaults_are_distinct_and_quality_ordered():
|
|||||||
assert router.PROFILE_ROUTE == {
|
assert router.PROFILE_ROUTE == {
|
||||||
"chat": "atlas/auto/fast",
|
"chat": "atlas/auto/fast",
|
||||||
"triage": "atlas/auto/deep",
|
"triage": "atlas/auto/deep",
|
||||||
"agent": "atlas/auto/maximum",
|
"agent": "atlas/auto/balanced",
|
||||||
}
|
}
|
||||||
assert router.PROFILE_ROUTE[router.ROUTER_PROFILE] in router.AUTO_ROUTES
|
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"
|
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(
|
def test_ui_priority_changes_auto_posture_without_selecting_a_target(
|
||||||
tmp_path, monkeypatch
|
tmp_path, monkeypatch
|
||||||
):
|
):
|
||||||
|
|||||||
@ -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():
|
def test_agent_uses_one_native_kanban_control_plane():
|
||||||
configmap = yaml.safe_load((HERMES / "agent-configmap.yaml").read_text())
|
configmap = yaml.safe_load((HERMES / "agent-configmap.yaml").read_text())
|
||||||
config = yaml.safe_load(configmap["data"]["config.yaml"])
|
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"]["dispatch_in_gateway"] is True
|
||||||
assert config["kanban"]["default_assignee"] == "cli-auto"
|
assert config["kanban"]["default_assignee"] == "cli-auto"
|
||||||
assert config["plugins"]["enabled"] == ["auto-router"]
|
assert config["plugins"]["enabled"] == ["auto-router"]
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user