Initial import of NousResearch/hermes-agent
Deploy Site / deploy-vercel (push) Has been cancelled
Deploy Site / deploy-docs (push) Has been cancelled
Docker / shell lint / Lint Dockerfile (hadolint) (push) Has been cancelled
Docker / shell lint / Lint docker/ shell scripts (shellcheck) (push) Has been cancelled
Docker Build and Publish / build-amd64 (push) Has been cancelled
Docker Build and Publish / build-arm64 (push) Has been cancelled
Lint (ruff + ty) / ruff + ty diff (push) Has been cancelled
Lint (ruff + ty) / ruff enforcement (blocking) (push) Has been cancelled
Lint (ruff + ty) / Windows footguns (blocking) (push) Has been cancelled
Nix Lockfile Fix / auto-fix-main (push) Has been cancelled
Nix Lockfile Fix / fix (push) Has been cancelled
Nix / nix (macos-latest) (push) Has been cancelled
Nix / nix (ubuntu-latest) (push) Has been cancelled
OSV-Scanner / Scan lockfiles (push) Has been cancelled
Build Skills Index / build-index (push) Has been cancelled
Tests / test (1) (push) Has been cancelled
Tests / test (2) (push) Has been cancelled
Tests / test (3) (push) Has been cancelled
Tests / test (4) (push) Has been cancelled
Tests / test (5) (push) Has been cancelled
Tests / test (6) (push) Has been cancelled
Tests / e2e (push) Has been cancelled
uv.lock check / uv lock --check (push) Has been cancelled
Docker Build and Publish / merge (push) Has been cancelled
Build Skills Index / trigger-deploy (push) Has been cancelled
Tests / save-durations (push) Has been cancelled

This commit is contained in:
红尘
2026-05-31 09:36:58 +08:00
commit d73ff9b0fb
4188 changed files with 1614916 additions and 0 deletions
@@ -0,0 +1,97 @@
"""Regression tests for gateway runtime config env-var expansion."""
from __future__ import annotations
import json
import pytest
import gateway.run as gateway_run
def _write_config(home, body: str) -> None:
(home / "config.yaml").write_text(body, encoding="utf-8")
@pytest.fixture
def gateway_home(monkeypatch, tmp_path):
monkeypatch.setattr(gateway_run, "_hermes_home", tmp_path)
monkeypatch.delenv("HERMES_PREFILL_MESSAGES_FILE", raising=False)
monkeypatch.delenv("HERMES_EPHEMERAL_SYSTEM_PROMPT", raising=False)
monkeypatch.delenv("HERMES_GATEWAY_BUSY_INPUT_MODE", raising=False)
monkeypatch.delenv("HERMES_RESTART_DRAIN_TIMEOUT", raising=False)
monkeypatch.delenv("HERMES_BACKGROUND_NOTIFICATIONS", raising=False)
return tmp_path
def test_load_prefill_messages_expands_env_var_path(monkeypatch, gateway_home):
prefill = [{"role": "system", "content": "few-shot"}]
(gateway_home / "prefill.json").write_text(json.dumps(prefill), encoding="utf-8")
_write_config(gateway_home, "prefill_messages_file: ${PREFILL_FILE}\n")
monkeypatch.setenv("PREFILL_FILE", "prefill.json")
assert gateway_run.GatewayRunner._load_prefill_messages() == prefill
@pytest.mark.parametrize(
("config_body", "env_name", "env_value", "loader_name", "expected"),
[
(
"agent:\n system_prompt: ${GW_PROMPT}\n",
"GW_PROMPT",
"expanded prompt",
"_load_ephemeral_system_prompt",
"expanded prompt",
),
(
"agent:\n reasoning_effort: ${REASONING_LEVEL}\n",
"REASONING_LEVEL",
"high",
"_load_reasoning_config",
{"enabled": True, "effort": "high"},
),
(
"agent:\n service_tier: ${SERVICE_TIER}\n",
"SERVICE_TIER",
"priority",
"_load_service_tier",
"priority",
),
(
"display:\n busy_input_mode: ${BUSY_MODE}\n",
"BUSY_MODE",
"steer",
"_load_busy_input_mode",
"steer",
),
(
"agent:\n restart_drain_timeout: ${DRAIN_TIMEOUT}\n",
"DRAIN_TIMEOUT",
"12",
"_load_restart_drain_timeout",
12.0,
),
(
"display:\n background_process_notifications: ${BG_MODE}\n",
"BG_MODE",
"error",
"_load_background_notifications_mode",
"error",
),
],
)
def test_gateway_runtime_loaders_expand_env_var_templates(
monkeypatch,
gateway_home,
config_body,
env_name,
env_value,
loader_name,
expected,
):
_write_config(gateway_home, config_body)
monkeypatch.setenv(env_name, env_value)
loader = getattr(gateway_run.GatewayRunner, loader_name)
assert loader() == expected