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
test(hermes-plugin): cover native patch on current Hermes (#6113)
z1gon8d28ffcdbb64
diff --git a/.github/workflows/hermes-plugin-tests.yml b/.github/workflows/hermes-plugin-tests.ymlindex c073e5e78..a226c1960 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: 7951ddd7297a284d6da48804241ee05a8a0c621c+ ref: db44c46208f1b421b4ecb7e56bf9d68b0423906fpath: .ci/hermes-agentpersist-credentials: false@@ -51,20 +51,12 @@ jobs:enable-cache: truecache-dependency-glob: |.ci/hermes-agent/uv.lock- examples/hermes-plugin/pyproject.toml+ .ci/hermes-agent/pm/lock.json- - name: Install the host and plugin test dependencies+ - name: Build the reviewed host test environmentworking-directory: .ci/hermes-agentrun: |- uv sync --frozen --group dev --no-install-project- uv export --frozen --group dev --no-emit-project --no-hashes \- --output-file "$RUNNER_TEMP/hermes-plugin-constraints.txt"- # Keep plugin dependencies within the reviewed host pins. PyYAML- # is used by the test fixtures; its version matches Hermes's lock.- uv pip install --python .venv/bin/python \- --constraint "$RUNNER_TEMP/hermes-plugin-constraints.txt" \- --requirement "$GITHUB_WORKSPACE/examples/hermes-plugin/pyproject.toml" \- 'PyYAML==6.0.3'+ python -m pm.build_env --source . --out .venv --group dev --group test- name: Run the external memory provider testsworking-directory: .ci/hermes-agent@@ -116,7 +108,7 @@ jobs:- uses: actions/checkout@v6with:repository: NousResearch/hermes-agent- ref: ${{ matrix.hermes_ref || '7951ddd7297a284d6da48804241ee05a8a0c621c' }}+ ref: ${{ matrix.hermes_ref || 'db44c46208f1b421b4ecb7e56bf9d68b0423906f' }}path: .ci/hermes-agentpersist-credentials: false- uses: actions/setup-python@v6@@ -128,19 +120,27 @@ jobs:enable-cache: truecache-dependency-glob: |.ci/hermes-agent/uv.lock- examples/hermes-plugin/local_packages.py+ .ci/hermes-agent/pm/lock.json- name: Install the reviewed host and test dependenciesrun: |if [ '${{ matrix.host }}' = release ]; then- uv sync --frozen --extra dev --no-install-project+ uv sync --python '${{ matrix.python }}' --frozen --extra dev --no-install-project+ uv pip install --python .venv/bin/python PyYAML==6.0.3else- uv sync --frozen --group dev --no-install-project+ python -m pm.build_env --source . --out .venv --group dev --group testfi- PYTHON=$(uv run --no-sync python -c 'import sys; print(sys.executable)')- uv pip install --python "$PYTHON" PyYAML==6.0.3+ if [ -x .venv/Scripts/python.exe ]; then+ PYTHON="$PWD/.venv/Scripts/python.exe"+ else+ PYTHON="$PWD/.venv/bin/python"+ fi+ echo "HERMES_PYTHON=$PYTHON" >> "$GITHUB_ENV"- name: Check process ownership and installer failures+ env:+ HERMES_TEST_FILE_RETRIES: '0'+ HERMES_TEST_WORKERS: '2'run: |- uv run --no-sync python -m pytest \+ scripts/run_tests.sh \"$GITHUB_WORKSPACE/examples/hermes-plugin/tests/test_local_lifecycle.py" \"$GITHUB_WORKSPACE/examples/hermes-plugin/tests/test_quick_local.py" \"$GITHUB_WORKSPACE/examples/hermes-plugin/tests/test_quick_local_routes.py" \@@ -152,14 +152,13 @@ jobs: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" \+ 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=()if [ '${{ matrix.host }}' = release ]; then ARGS+=(--legacy-uv); fi- uv run --no-sync python "$GITHUB_WORKSPACE/scripts/check-hermes-quick-local.py" \+ "$HERMES_PYTHON" "$GITHUB_WORKSPACE/scripts/check-hermes-quick-local.py" \--hermes-root "$PWD" --output-dir "$RUNNER_TEMP/quick-local" "${ARGS[@]}"- uses: actions/upload-artifact@v4if: always()diff --git a/examples/hermes-plugin/CONFIGURATION.md b/examples/hermes-plugin/CONFIGURATION.mdindex 05ed556fc..1a42f741d 100644--- a/examples/hermes-plugin/CONFIGURATION.md+++ b/examples/hermes-plugin/CONFIGURATION.md@@ -264,6 +264,12 @@ OpenViking in order. The active profile records each copied entry's exact URI in| `replace` | Match the committed event's full previous content and target, update the same URI, and wait for semantic/vector refresh || `remove` | Match the committed event's full previous content and target, delete that exact URI, and wait for semantic cleanup |+Hermes v0.22 and later expose `patch` instead of `replace` in the native+`memory` tool. After a successful patch, Hermes sends the provider a `replace`+event containing the complete updated entry and its full previous content.+Older Hermes releases expose `replace` directly. Both paths update the same+mapped OpenViking URI.+Replacing a mapped entry recreates its file if it was deleted directly inOpenViking, for example with `viking_forget`.diff --git a/examples/hermes-plugin/DEVELOPMENT.md b/examples/hermes-plugin/DEVELOPMENT.mdindex ae3ce383c..fecca6ac7 100644--- a/examples/hermes-plugin/DEVELOPMENT.md+++ b/examples/hermes-plugin/DEVELOPMENT.md@@ -122,13 +122,21 @@ The `Hermes Plugin Tests` workflow runs this directory's complete external-provisuite 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.+with Python 3.13, selected explicitly by `uv sync --python` rather than the+release checkout's `.python-version`. 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-servicevalidation remains part of release testing.+The reviewed current host builds its test environment through Hermes PM.+Fixtures use the host's YAML implementation, so they do not need a separate+PyYAML install on current Hermes. The older release retains its uv installer.+Native edit tests select the action advertised by the host tool schema:+`patch` on current Hermes and `replace` on the release baseline. Both must+update the same mapped file. Patch-specific tests also check that text outside+the edited span is preserved in the native entry and its remote copy.CI also runs `scripts/check-hermes-plugin-install.py` through the real HermesCLI in an isolated profile. It installs this repository's plugin subdirectory,@@ -143,7 +151,9 @@ The complete mirror tests require the committed-entry event contract introducedin [Hermes PR #118903](https://github.com/NousResearch/hermes-agent/pull/118903)and merged through [#120003](https://github.com/NousResearch/hermes-agent/pull/120003)(commit `5908e1aaa83e82aaf12541d7a9d90762d0b46a64`):-`MemoryManager` forwards `previous_content` for each successful replace/remove.+`MemoryManager` forwards `previous_content` for each successful replacement or+removal. Current native `patch` calls become provider `replace` events containing+the complete updated entry; older native `replace` calls use that event directly.The legacy compatibility tests verify that missing metadata skips these remotemutations. Do not substitute a guessed match in tests or production.diff --git a/examples/hermes-plugin/tests/test_gateway_recall.py b/examples/hermes-plugin/tests/test_gateway_recall.pyindex 283f7ffb1..243edb321 100644--- a/examples/hermes-plugin/tests/test_gateway_recall.py+++ b/examples/hermes-plugin/tests/test_gateway_recall.py@@ -8,7 +8,7 @@ from types import SimpleNamespaceimport httpximport pytest-import yaml+from hermes_cli.config import yaml@contextmanagerdiff --git a/examples/hermes-plugin/tests/test_native_memory_bridge.py b/examples/hermes-plugin/tests/test_native_memory_bridge.pyindex dc1f652f9..2f711171a 100644--- a/examples/hermes-plugin/tests/test_native_memory_bridge.py+++ b/examples/hermes-plugin/tests/test_native_memory_bridge.py@@ -45,6 +45,17 @@ def _drain(provider):time.sleep(0.01)+def _edit(old_text, content):+ from tools.memory_tool import MEMORY_SCHEMA++ actions = MEMORY_SCHEMA["parameters"]["properties"]["action"]["enum"]+ return {+ "action": "patch" if "patch" in actions else "replace",+ "old_text": old_text,+ "new_text": content,+ }++@contextmanagerdef _bridge(external_provider):from agent.memory_manager import MemoryManager@@ -78,7 +89,7 @@ def _bridge(external_provider):@pytest.mark.parametrize("mapped", [False, True])@pytest.mark.parametrize("batch", [False, True])[email protected]("action", ["remove", "replace"])[email protected]("action", ["remove", "edit"])def test_native_exact_entry_does_not_mutate_its_longer_sibling(external_provider, mapped, batch, action):@@ -88,8 +99,8 @@ def test_native_exact_entry_does_not_mutate_its_longer_sibling(assert invoke({"action": "add", "content": "Prefers tea with milk"})["success"]expected = dict(client.files)operation = {"action": action, "old_text": "Prefers tea"}- if action == "replace":- operation["new_text"] = "Prefers coffee"+ if action == "edit":+ operation = _edit("Prefers tea", "Prefers coffee")if mapped:expected[exact_uri] = "Prefers coffee"elif mapped:@@ -97,7 +108,7 @@ def test_native_exact_entry_does_not_mutate_its_longer_sibling(assert invoke(operation, batch=batch)["success"]assert store.user_entries == (["Prefers coffee", "Prefers tea with milk"]- if action == "replace"+ if action == "edit"else ["Prefers tea with milk"])assert client.files == expected@@ -105,13 +116,15 @@ def test_native_exact_entry_does_not_mutate_its_longer_sibling(def test_committed_batch_mirrors_each_intermediate_entry_in_order(external_provider):with _bridge(external_provider) as (home, _, client, store, invoke):+ # An unrelated native entry must survive the mirrored batch unchanged.+ assert invoke({"action": "add", "content": "Keep this entry"}, mirror=False)["success"]assert invoke({"action": "add", "content": "Prefers tea"},- {"action": "replace", "old_text": "tea", "new_text": "Prefers coffee"},+ _edit("Prefers tea", "Prefers coffee"),{"action": "remove", "old_text": "coffee"},batch=True,)["success"]- assert store.user_entries == []+ assert store.user_entries == ["Keep this entry"]assert client.files == {}assert [(method, body.get("mode")) for method, body in client.requests] == [("write", "create"),@@ -132,7 +145,7 @@ def test_uncommitted_batch_has_no_remote_effect(external_provider, monkeypatch,before = store._path_for("user").read_bytes()operations = [{"action": "add", "content": "Prefers tea"},- {"action": "replace", "old_text": "tea", "content": "Prefers coffee"},+ _edit("Prefers tea", "Prefers coffee"),]if failure == "missing_entry":operations.append({"action": "remove", "old_text": "Absent entry"})@@ -148,7 +161,12 @@ def test_uncommitted_batch_has_no_remote_effect(external_provider, monkeypatch,with pytest.raises(OSError, match="disk unavailable"):invoke(*operations, batch=True)else:- assert not invoke(*operations, batch=True)["success"]+ result = invoke(*operations, batch=True)+ assert not result["success"]+ expected_error = (+ "no entry matched 'absent entry'" if failure == "missing_entry" else "chars"+ )+ assert expected_error in result["error"].lower()assert client.requests == []assert not getattr(provider, "_native_memory_mirror", None)assert not (home / "openviking/memory_mirror_registry.json").exists()@@ -184,9 +202,7 @@ def test_index_failure_preserves_mapping_for_next_replace_and_remove(uri = next(iter(client.files))client.refresh_failure = failed_statuswith caplog.at_level("WARNING", logger="plugins.memory.openviking"):- assert invoke({"action": "replace", "old_text": "tea", "content": "Prefers coffee"})[- "success"- ]+ assert invoke(_edit("Prefers tea", "Prefers coffee"))["success"]path = home / "openviking/memory_mirror_registry.json"entry = json.loads(path.read_text())["entries"][0]assert entry["uri"] == uri@@ -198,10 +214,27 @@ def test_index_failure_preserves_mapping_for_next_replace_and_remove(for record in caplog.records)client.refresh_failure = None- assert invoke({"action": "replace", "old_text": "coffee", "content": "Prefers water"})[- "success"- ]+ assert invoke(_edit("Prefers coffee", "Prefers water"))["success"]assert client.files == {uri: "Prefers water"}assert invoke({"action": "remove", "old_text": "water"})["success"]assert client.files == {}assert json.loads(path.read_text())["entries"] == []++[email protected]("batch", [False, True])+def test_native_patch_mirrors_the_complete_updated_entry(external_provider, batch):+ if _edit("tea", "coffee")["action"] != "patch":+ pytest.skip("This Hermes release predates the native patch action")++ with _bridge(external_provider) as (home, _, client, store, invoke):+ assert invoke({"action": "add", "content": "Prefers tea with milk"})["success"]+ uri = next(iter(client.files))+ assert invoke(_edit("tea", "coffee"), batch=batch)["success"]+ assert store.user_entries == ["Prefers coffee with milk"]+ assert client.files == {uri: "Prefers coffee with milk"}+ entries = json.loads((home / "openviking/memory_mirror_registry.json").read_text())[+ "entries"+ ]+ assert len(entries) == 1+ assert entries[0]["content"] == "Prefers coffee with milk"+ assert entries[0]["uri"] == uridiff --git a/examples/hermes-plugin/tests/test_setup_profiles.py b/examples/hermes-plugin/tests/test_setup_profiles.pyindex 83085f44c..0788e5f78 100644--- a/examples/hermes-plugin/tests/test_setup_profiles.py+++ b/examples/hermes-plugin/tests/test_setup_profiles.py@@ -4,7 +4,7 @@ import copyfrom types import SimpleNamespaceimport pytest-import yaml+from hermes_cli.config import yamldef patch_menu(monkeypatch, select):diff --git a/examples/hermes-plugin/tests/test_standalone.py b/examples/hermes-plugin/tests/test_standalone.pyindex 07450e44e..8b5faabee 100644--- a/examples/hermes-plugin/tests/test_standalone.py+++ b/examples/hermes-plugin/tests/test_standalone.py@@ -675,8 +675,7 @@ def test_external_provider_does_not_cache_unbound_client_identity(external_providef test_save_config_targets_explicit_home_and_restores_outer_scope(external_provider, tmp_path, monkeypatch):- import yaml-+ from hermes_cli.config import yamlfrom hermes_constants import reset_hermes_home_override, set_hermes_home_override_, provider, _, _ = external_provider("config-provider")