Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
fix(hermes-plugin): filter server secrets on released Hermes (#5706)
z1gona768dfb55235
diff --git a/.github/workflows/hermes-plugin-tests.yml b/.github/workflows/hermes-plugin-tests.ymlindex 6898dc9fa..c073e5e78 100644--- a/.github/workflows/hermes-plugin-tests.yml+++ b/.github/workflows/hermes-plugin-tests.yml@@ -37,7 +37,7 @@ jobs:uses: actions/checkout@v6with:repository: NousResearch/hermes-agent- ref: 5bba024d8ddd388f56f354c1f789be825e3d8a3c+ ref: 7951ddd7297a284d6da48804241ee05a8a0c621cpath: .ci/hermes-agentpersist-credentials: false@@ -102,7 +102,7 @@ jobs:- os: ubuntu-24.04host: releasepython: '3.13'- hermes_ref: e3dd27ee2d8b011737a4eea8e3eb3d711ab78690 # v2026.9.24, pre-PM+ hermes_ref: v2026.9.24runs-on: ${{ matrix.os }}timeout-minutes: 30defaults:@@ -116,7 +116,7 @@ jobs:- uses: actions/checkout@v6with:repository: NousResearch/hermes-agent- ref: ${{ matrix.hermes_ref || '5bba024d8ddd388f56f354c1f789be825e3d8a3c' }}+ ref: ${{ matrix.hermes_ref || '7951ddd7297a284d6da48804241ee05a8a0c621c' }}path: .ci/hermes-agentpersist-credentials: false- uses: actions/setup-python@v6@@ -146,6 +146,15 @@ jobs:"$GITHUB_WORKSPACE/examples/hermes-plugin/tests/test_quick_local_routes.py" \"$GITHUB_WORKSPACE/examples/hermes-plugin/tests/test_quick_local_preflight.py" \--confcutdir="$GITHUB_WORKSPACE/examples/hermes-plugin/tests" -p no:cacheprovider -q+ - name: Run the complete provider suite on the release host+ if: matrix.host == 'release'+ env:+ HERMES_TEST_FILE_RETRIES: '0'+ HERMES_TEST_WORKERS: '2'+ run: |+ HERMES_PYTHON=$(uv run --no-sync python -c 'import sys; print(sys.executable)') \+ scripts/run_tests.sh "$GITHUB_WORKSPACE/examples/hermes-plugin/tests" \+ --confcutdir="$GITHUB_WORKSPACE/examples/hermes-plugin/tests" -p no:cacheprovider -q- name: Install and run real Quick Local servicesrun: |ARGS=()diff --git a/examples/hermes-plugin/DEVELOPMENT.md b/examples/hermes-plugin/DEVELOPMENT.mdindex c421a2228..4f6b61a40 100644--- a/examples/hermes-plugin/DEVELOPMENT.md+++ b/examples/hermes-plugin/DEVELOPMENT.md@@ -108,6 +108,10 @@ tested release baseline. It does not add server dependencies to Hermes.The `Hermes Plugin Tests` workflow runs this directory's complete external-providersuite on plugin changes, pushes to `main`/`develop`, and manual dispatch.It uses Python 3.14 and a reviewed Hermes commit, with test retries disabled.+The release-host job runs the complete provider suite on Hermes v2026.9.24+with Python 3.13. Legacy autostart uses Hermes's profile environment helper and+credential scrubber on both hosts. Unrelated process and profile secrets are+removed; missing helpers or secret-scope errors prevent spawning.When updating the host SHA in `.github/workflows/hermes-plugin-tests.yml`, checkthe host dependency pins and run the suite before submitting the change.These regression tests use mock responses and local test servers; live-servicediff --git a/examples/hermes-plugin/README.md b/examples/hermes-plugin/README.mdindex 4eb2c38b5..771fb1785 100644--- a/examples/hermes-plugin/README.md+++ b/examples/hermes-plugin/README.md@@ -13,7 +13,8 @@ For development and licensing details, see [DEVELOPMENT.md](DEVELOPMENT.md).## Install-Hermes v2026.9.24 is the tested release baseline.+Validated with Hermes v2026.9.24. CI also checks the reviewed Hermes main+commit pinned in the [test workflow](../../.github/workflows/hermes-plugin-tests.yml).For a direct installation, replace the placeholder with the reviewed OpenVikingcommit's full 40-character SHA:diff --git a/examples/hermes-plugin/__init__.py b/examples/hermes-plugin/__init__.pyindex 772c59582..2d6b4fd86 100644--- a/examples/hermes-plugin/__init__.py+++ b/examples/hermes-plugin/__init__.py@@ -1110,7 +1110,7 @@ def _local_listener_suffix(endpoint: str) -> str:return f" The listener on {host}:{port} is {_describe_local_port_listener(host, port)}."-def _start_local_openviking_server(endpoint: str) -> tuple[str, str]:+def _start_local_openviking_server(endpoint: str, *, hermes_home=None) -> tuple[str, str]:try:host, port = _local_openviking_bind(endpoint)except ValueError as e:@@ -1126,7 +1126,7 @@ def _start_local_openviking_server(endpoint: str) -> tuple[str, str]:server_cmd = shutil.which("openviking-server")if not server_cmd:return _LOCAL_SERVER_FAILED, "openviking-server was not found on PATH. Start it manually, then retry."- log_path = get_hermes_home() / _OPENVIKING_SERVER_LOG_RELATIVE_PATH+ log_path = Path(hermes_home or get_hermes_home()) / _OPENVIKING_SERVER_LOG_RELATIVE_PATHtry:log_path.parent.mkdir(parents=True, exist_ok=True)# Strip PYTHONPATH: the Desktop backend puts the Hermes venv on it, which@@ -1136,7 +1136,33 @@ def _start_local_openviking_server(endpoint: str) -> tuple[str, str]:# would import aiohttp and friends from the Hermes venv instead of its own (its venv's site-packages# are shadowed because PYTHONPATH precedes them) — and on Windows the loaded DLLs then lock the# Hermes venv, aborting `hermes update` with access-denied on .pyd files. (#78153)- child_env = os.environ.copy()+ # The server's embedding/VLM models may read provider keys, so the bound profile's pass;+ # bot, gateway and GitHub tokens never do. HOME stays the user's: ov.conf defaults to+ # ~/.openviking. Missing helpers fail startup rather than expose secrets.+ from hermes_cli.config import OPTIONAL_ENV_VARS+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override+ from tools.environments.local import _finalize_child_env, _scrub_credentials, served_profile_child_env++ home_token = set_hermes_home_override(hermes_home) if hermes_home else None+ try:+ # Profile hydration can re-add bot tokens. Reuse Hermes's credential+ # policy after the overlay; these helpers predate the base_env API.+ child_env = _scrub_credentials(+ served_profile_child_env(target_home=hermes_home, inherit_credentials=True), inherit_credentials=True)+ # Older hosts put gateway secrets in optional-credential metadata.+ # Preserve model variables, including providers Hermes does not list.+ for key in list(child_env):+ metadata = OPTIONAL_ENV_VARS.get(key.upper(), {})+ if (metadata.get("category") == "messaging"+ or (metadata.get("category") == "setting" and metadata.get("password"))+ or key.upper() in {"VERCEL_TOKEN", "VERCEL_OIDC_TOKEN"}):+ child_env.pop(key)+ child_env = _finalize_child_env(child_env)+ finally:+ if home_token is not None:+ reset_hermes_home_override(home_token)+ if real_home := child_env.get("HERMES_REAL_HOME"):+ child_env["HOME"] = real_homechild_env.pop("PYTHONPATH", None)with log_path.open("ab") as log_file:subprocess.Popen([server_cmd, "--host", host, "--port", str(port)], stdout=log_file, stderr=log_file,@@ -1649,7 +1675,7 @@ class OpenVikingMemoryProvider(MemoryProvider):endpoint = self._endpointstart_state, start_message = _LOCAL_SERVER_STARTED, f"Starting Quick Local at {endpoint}. Logs: {server.paths.root.parent / _OPENVIKING_SERVER_LOG_RELATIVE_PATH}"else:- start_state, start_message = _start_local_openviking_server(endpoint)+ start_state, start_message = _start_local_openviking_server(endpoint, hermes_home=self._hermes_home)except Exception as exc:logger.debug("OpenViking startup failed", exc_info=True)start_state, start_message = _LOCAL_SERVER_FAILED, f"Startup failed ({type(exc).__name__}). Review the server log."diff --git a/examples/hermes-plugin/tests/test_standalone.py b/examples/hermes-plugin/tests/test_standalone.pyindex d840b79a9..089fc672d 100644--- a/examples/hermes-plugin/tests/test_standalone.py+++ b/examples/hermes-plugin/tests/test_standalone.py@@ -1215,3 +1215,109 @@ def test_reload_back_to_original_identity_keeps_new_generation_pending(reload_prassert bob_marker.exists()commits = [c for c in backends["alice"].post.call_args_list if c.args[0].endswith("/commit")]assert len(commits) == 2+++def test_local_server_spawn_drops_unrelated_secrets(external_provider, monkeypatch):+ _, _, module, _ = external_provider("profile-a")+ monkeypatch.setenv("TELEGRAM_BOT_TOKEN", "sentinel-bot-token")+ monkeypatch.setenv("OPENAI_API_KEY", "sentinel-embedding-key")+ monkeypatch.setenv("PYTHONPATH", "/hermes/venv/site-packages")+ monkeypatch.setattr(module, "_local_openviking_port_is_open", lambda *_: False)+ monkeypatch.setattr(module.shutil, "which", lambda _: "openviking-server")+ spawned = []+ monkeypatch.setattr(module.subprocess, "Popen", lambda argv, **kwargs: spawned.append(kwargs["env"]))++ status, _ = module._start_local_openviking_server("http://127.0.0.1:1933")++ assert status == module._LOCAL_SERVER_STARTED+ (env,) = spawned+ assert "TELEGRAM_BOT_TOKEN" not in env+ assert "PYTHONPATH" not in env+ assert env["OPENAI_API_KEY"] == "sentinel-embedding-key"+++def test_local_server_spawn_scrubs_profile_overlay(external_provider, monkeypatch, tmp_path):+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override+ from tools.environments.local import _HERMES_PROVIDER_ENV_FORCE_PREFIX++ monkeypatch.setenv("OPENAI_API_KEY", "launch-key")+ monkeypatch.setenv("GH_TOKEN", "launch-gh-token")+ monkeypatch.setenv("HOME", str(tmp_path))+ monkeypatch.setenv("HERMES_REAL_HOME", str(tmp_path))+ monkeypatch.setenv(_HERMES_PROVIDER_ENV_FORCE_PREFIX + "OPENAI_API_KEY", "forced-key")+ spawned = []+ for name in ("a", "b", "a"):+ home, _, module, _ = external_provider("spawn-" + name)+ (home / ".env").write_text(+ f"OPENAI_API_KEY=key-{name}\nTELEGRAM_BOT_TOKEN=bot-{name}\ngh_token=gh-{name}\n"+ "FEISHU_APP_SECRET=feishu-key\nqq_client_secret=qq-key\nAPI_SERVER_KEY=gateway-key\n"+ "VERCEL_TOKEN=vercel-key\nVERCEL_OIDC_TOKEN=vercel-oidc\n"+ "PYTHONHOME=/other-python\nVIRTUAL_ENV=/other-venv\nCONDA_PREFIX=/other-conda\n",+ encoding="utf-8",+ )+ monkeypatch.setattr(module, "_local_openviking_port_is_open", lambda *_: False)+ monkeypatch.setattr(module.shutil, "which", lambda _: "openviking-server")+ monkeypatch.setattr(module.subprocess, "Popen", lambda argv, **kwargs: spawned.append(kwargs["env"]))+ token = set_hermes_home_override(home)+ try:+ status, message = module._start_local_openviking_server("http://127.0.0.1:1933")+ assert status == module._LOCAL_SERVER_STARTED, message+ finally:+ reset_hermes_home_override(token)+ env = spawned[-1]+ assert env["OPENAI_API_KEY"] == "key-" + name+ assert env["HERMES_HOME"] == str(home)+ assert env["HOME"] == str(tmp_path)+ assert not {"GH_TOKEN", "gh_token", "TELEGRAM_BOT_TOKEN", "PYTHONPATH"} & env.keys()+ assert not {"FEISHU_APP_SECRET", "qq_client_secret", "API_SERVER_KEY", "VERCEL_TOKEN",+ "VERCEL_OIDC_TOKEN", "PYTHONHOME", "VIRTUAL_ENV", "CONDA_PREFIX"} & env.keys()+ assert not any(key.startswith(_HERMES_PROVIDER_ENV_FORCE_PREFIX) for key in env)++[email protected]("failure", ["missing_helper", "unscoped"])+def test_local_server_spawn_fails_closed(external_provider, monkeypatch, failure):+ from tools.environments import local++ _, _, module, _ = external_provider("spawn-failure")+ if failure == "missing_helper":+ monkeypatch.delattr(local, "_scrub_credentials")+ else:+ monkeypatch.setattr("agent.secret_scope._MULTIPLEX_ACTIVE", True)+ monkeypatch.setattr("agent.secret_scope.current_secret_scope", lambda: None)+ monkeypatch.setattr("hermes_constants.get_hermes_home_override", lambda: None)+ monkeypatch.setattr(module, "_local_openviking_port_is_open", lambda *_: False)+ monkeypatch.setattr(module.shutil, "which", lambda _: "openviking-server")+ spawned = []+ monkeypatch.setattr(module.subprocess, "Popen", lambda *args, **kwargs: spawned.append(kwargs))++ status, _ = module._start_local_openviking_server("http://127.0.0.1:1933")++ assert status == module._LOCAL_SERVER_FAILED+ assert not spawned+++def test_runtime_spawn_uses_provider_home_under_another_profile(external_provider, monkeypatch):+ from hermes_constants import reset_hermes_home_override, set_hermes_home_override++ home_a, provider, module, _ = external_provider("runtime-owner")+ home_b, _, _, _ = external_provider("runtime-caller")+ for home, key in ((home_a, "owner-key"), (home_b, "caller-key")):+ (home / ".env").write_text("OPENAI_API_KEY=" + key + "\n", encoding="utf-8")+ provider._hermes_home, provider._hermes_home_bound = str(home_a), True+ provider._endpoint = "http://127.0.0.1:1933"+ monkeypatch.setattr(module, "_local_openviking_port_is_open", lambda *_: False)+ monkeypatch.setattr(module.shutil, "which", lambda _: "openviking-server")+ monkeypatch.setattr(provider, "_start_runtime_openviking_waiter", lambda **kwargs: None)+ spawned = []+ monkeypatch.setattr(module.subprocess, "Popen", lambda argv, **kwargs: spawned.append(kwargs["env"]))+ token = set_hermes_home_override(home_b)+ try:+ provider._handle_runtime_openviking_unreachable()+ finally:+ reset_hermes_home_override(token)++ assert len(spawned) == 1+ assert spawned[0]["HERMES_HOME"] == str(home_a)+ assert spawned[0]["OPENAI_API_KEY"] == "owner-key"+ assert (home_a / "logs/openviking-server.log").exists()+ assert not (home_b / "logs/openviking-server.log").exists()