Skip to content

Hermes Agent context engine: the main model writes the compaction handoff on its cached prompt prefix

Require the summary end marker to end the carrier

Elevatormusicd678d5d4d609
diff --git a/evidence/plugin-integration.json b/evidence/plugin-integration.json
index 8c651ac..ea07d03 100644
--- a/evidence/plugin-integration.json
+++ b/evidence/plugin-integration.json
@@ -1,6 +1,6 @@
{
"check": "standalone warm_compaction plugin on unpatched Hermes Agent",
- "started_utc": "2026-10-06T16:27:26Z",
+ "started_utc": "2026-10-06T16:38:44Z",
"hermes": {
"commit": "45871e100feceb89769536c88e5e6e265226a409",
"clean": true
@@ -13,7 +13,7 @@
"warm_compaction/engine.py": "c46e5ac2041599bb48983a7cfe990412cc1669ba9f2f834d9d71b55db31064a4",
"warm_compaction/fallback.py": "f4cf08186f38fc9a46f47af2bedf22584b6ede4f11de1c3abd0fd598aec2f8a4",
"warm_compaction/handoff.py": "9afea62ec2f8ef46cbeefd70b1071bb6c7111fa6fd1cd073e1fb2c7eae30f3c2",
- "warm_compaction/layout.py": "02ddc09b79e15fb1a81d09369f6deed3a1068cda6907ab59aae71b8cc98c3b49",
+ "warm_compaction/layout.py": "fc410c192acfbea60e2137172b9fcf82091f3b51c8a0c8e007bc363bb2dfd01b",
"warm_compaction/plugin.yaml": "d67560fd4625ec80d9e26f3e6d712763e77474f68d469c7e48f09fd3506ccc71",
"warm_compaction/rows.py": "1eb0a043c060322769ad0e2533b3f1b30d5258f125502752d18b8a94c1006347",
"warm_compaction/warm.py": "fe1f1b2e065f7198586979455ab54ed7dfd20d144b3751c3451d3cf6a70480e4"
@@ -76,11 +76,11 @@
"threshold_tokens": 100000,
"context_length": 200000
},
- "compress_seconds": 0.102,
+ "compress_seconds": 0.114,
"warm_last": {
"path": "warm",
"reason": "accepted",
- "elapsed_s": 0.025,
+ "elapsed_s": 0.028,
"prompt_tokens": 33892,
"cached_tokens": 16946
},
@@ -88,10 +88,11 @@
"final_session_id": "wc-enable_manual_warm",
"continuation_keeps_custom_system_text": false,
"fence_denied": {
- "network_host_blocked": 1,
- "child_process_blocked": 3
+ "child_process_blocked": 4,
+ "network_host_blocked": 1
},
"fence_blocked_programs": [
+ "git",
"pip",
"python",
"python3"
@@ -100,6 +101,7 @@
"hermes-assets.nousresearch.com"
],
"fence_blocked_callers": [
+ "child_process_blocked from hermes_cli/source_check.py:_git_run < hermes_cli/source_check.py:_git_stdout < hermes_cli/source_check.py:_read_checkout",
"child_process_blocked from tools/env_probe.py:_run < tools/env_probe.py:_py_out < tools/env_probe.py:_pip_python_version",
"child_process_blocked from tools/env_probe.py:_run < tools/env_probe.py:_py_out < tools/env_probe.py:_python_version_of",
"network_host_blocked from hermes_cli/release_channels.py:read < hermes_cli/release_channels.py:read_bytes < hermes_cli/release_channels.py:read_record"
@@ -187,7 +189,7 @@
"install",
"run"
],
- "process_seconds": 53.772
+ "process_seconds": 53.364
},
{
"scenario": "manual_fallback",
@@ -246,11 +248,11 @@
"threshold_tokens": 100000,
"context_length": 200000
},
- "compress_seconds": 0.248,
+ "compress_seconds": 0.282,
"warm_last": {
"path": "fallback",
"reason": "provider_error",
- "elapsed_s": 0.109,
+ "elapsed_s": 0.141,
"prompt_tokens": null,
"cached_tokens": null
},
@@ -359,7 +361,7 @@
"install",
"run"
],
- "process_seconds": 32.85
+ "process_seconds": 34.145
},
{
"scenario": "manual_fixed",
@@ -417,11 +419,11 @@
"threshold_tokens": 100000,
"context_length": 200000
},
- "compress_seconds": 0.239,
+ "compress_seconds": 0.26,
"warm_last": {
"path": "fixed",
"reason": "provider_error",
- "elapsed_s": 0.11,
+ "elapsed_s": 0.125,
"prompt_tokens": null,
"cached_tokens": null
},
@@ -530,7 +532,7 @@
"install",
"run"
],
- "process_seconds": 30.447
+ "process_seconds": 33.99
},
{
"scenario": "auto_tool_loop",
@@ -625,14 +627,14 @@
"warm_last_2": {
"path": "warm",
"reason": "accepted",
- "elapsed_s": 0.0,
+ "elapsed_s": 0.016,
"prompt_tokens": 19504,
"cached_tokens": 9752
},
"compression_count": 2,
"fence_denied": {
- "network_host_blocked": 1,
- "child_process_blocked": 7
+ "child_process_blocked": 8,
+ "network_host_blocked": 1
},
"fence_blocked_programs": [
"git",
@@ -646,6 +648,7 @@
"fence_blocked_callers": [
"child_process_blocked from hermes_cli/local_runtime/processes.py:spawn_server < hermes_cli/_subprocess_compat.py:bounded_probe_run < hermes_cli/_subprocess_compat.py:bounded_git_probe",
"child_process_blocked from hermes_cli/local_runtime/processes.py:spawn_server < hermes_cli/_subprocess_compat.py:bounded_probe_run < hermes_cli/_subprocess_compat.py:noninteractive_repo_git_env",
+ "child_process_blocked from hermes_cli/source_check.py:_git_run < hermes_cli/source_check.py:_git_stdout < hermes_cli/source_check.py:_read_checkout",
"child_process_blocked from tools/env_probe.py:_run < tools/env_probe.py:_py_out < tools/env_probe.py:_pip_python_version",
"child_process_blocked from tools/env_probe.py:_run < tools/env_probe.py:_py_out < tools/env_probe.py:_python_version_of",
"network_host_blocked from hermes_cli/release_channels.py:read < hermes_cli/release_channels.py:read_bytes < hermes_cli/release_channels.py:read_record"
@@ -734,7 +737,7 @@
"install",
"run"
],
- "process_seconds": 33.594
+ "process_seconds": 35.991
},
{
"scenario": "rollback",
@@ -784,7 +787,7 @@
"threshold_tokens": 100000,
"context_length": 200000
},
- "compress_seconds": 0.136,
+ "compress_seconds": 0.14,
"warm_last": {
"path": "warm",
"reason": "accepted",
@@ -796,7 +799,7 @@
"final_session_id": "wc-rollback",
"continuation_keeps_custom_system_text": false,
"fence_denied": {
- "child_process_blocked": 5,
+ "child_process_blocked": 4,
"network_host_blocked": 1
},
"fence_blocked_programs": [
@@ -947,7 +950,8 @@
"stored": 30
},
"fence_denied": {
- "child_process_blocked": 5
+ "child_process_blocked": 5,
+ "network_host_blocked": 1
},
"fence_blocked_programs": [
"git",
@@ -955,7 +959,9 @@
"python",
"python3"
],
- "fence_blocked_hosts": []
+ "fence_blocked_hosts": [
+ "hermes-assets.nousresearch.com"
+ ]
},
"exit": [
0,
@@ -967,10 +973,10 @@
"run",
"rollback"
],
- "process_seconds": 38.756
+ "process_seconds": 39.347
}
],
- "finished_utc": "2026-10-06T16:30:35Z",
+ "finished_utc": "2026-10-06T16:42:01Z",
"passed": true,
"run_folder": "outside repository"
}
diff --git a/tests/test_wc_layout.py b/tests/test_wc_layout.py
index a70b654..000ac12 100644
--- a/tests/test_wc_layout.py
+++ b/tests/test_wc_layout.py
@@ -45,7 +45,7 @@ class PredicateTest(unittest.TestCase):
def test_summary_detection(self):
# Without the flag (the Hermes session store drops it), only the whole carrier is a summary: a prefix and
# the end marker, or the plugin header row.
- self.assertTrue(is_summary(assistant("[CONTEXT SUMMARY]: s\n\n--- END OF CONTEXT SUMMARY x"), PREFIXES))
+ self.assertTrue(is_summary(assistant("[CONTEXT SUMMARY]: s\n\n--- END OF CONTEXT SUMMARY x ---"), PREFIXES))
self.assertTrue(is_summary(user("[HERMES PREFIX]\n\n" + HEADER_TEXT), PREFIXES))
self.assertTrue(is_summary(user("plain", _compressed_summary=True), PREFIXES))
self.assertFalse(is_summary(user("plain"), PREFIXES))
@@ -56,6 +56,22 @@ class PredicateTest(unittest.TestCase):
self.assertFalse(is_summary(row, PREFIXES))
self.assertTrue(is_real_user(row, PREFIXES))
+ def test_the_end_marker_must_end_the_carrier(self):
+ # The marker inside a request, or a marker line with the request after it, does not make a summary. A
+ # carrier ends with its marker line, or Hermes restates the active request after it (the replay header).
+ from warm_compaction.layout import INFLIGHT_REPLAY_HEADER
+ marker = "--- END OF CONTEXT SUMMARY - respond to the message below ---"
+ for text in ("[CONTEXT SUMMARY]: Please analyze this delimiter: --- END OF CONTEXT SUMMARY and then answer.",
+ "[CONTEXT SUMMARY]: s\n\n" + marker + "\n\nNow fix the parser.",
+ "[CONTEXT SUMMARY]: why does this end with\n" + marker + " in my log?"):
+ with self.subTest(text=text):
+ self.assertFalse(is_summary(user(text), PREFIXES))
+ self.assertTrue(is_real_user(user(text), PREFIXES))
+ for text in ("[CONTEXT SUMMARY]: s\n\n" + marker,
+ "[CONTEXT SUMMARY]: s\n\n" + marker + "\n\n" + INFLIGHT_REPLAY_HEADER + "\n\nfinish it"):
+ with self.subTest(text=text):
+ self.assertTrue(is_summary(user(text), PREFIXES))
+
class TailTest(unittest.TestCase):
def test_units_keep_tool_groups_whole(self):
diff --git a/warm_compaction/layout.py b/warm_compaction/layout.py
index 1e4ec40..e0acde5 100644
--- a/warm_compaction/layout.py
+++ b/warm_compaction/layout.py
@@ -79,17 +79,37 @@ def nudge_texts() -> frozenset[str]:
return frozenset(hermes_value(module, name, default).strip() for module, name, default in HOST_NUDGES)
+# Hermes 45871e10 (agent.context_compressor._INFLIGHT_TASK_REPLAY_HEADER): after the end marker of a carrier,
+# Hermes can restate the active request that was not finished.
+INFLIGHT_REPLAY_HEADER = ("[STILL IN PROGRESS \u2014 this is the active request, restated after the compaction "
+ "boundary because it was not finished yet. Continue it; do not start over.]")
+
+
+def _ends_carrier(text: str) -> bool:
+ """True when the text ends as a summary carrier: its last end-marker line (a whole line that starts with
+ END_MARKER and ends with ---, as each Hermes version writes it) has nothing after it, or only the Hermes
+ restatement of the active request. The marker inside a sentence, or a request after it, is user text."""
+ lines = text.split("\n")
+ for index in range(len(lines) - 1, -1, -1):
+ line = lines[index].strip()
+ if line.startswith(END_MARKER) and line.endswith("---"):
+ after = "\n".join(lines[index + 1:]).strip()
+ replay = hermes_value("agent.context_compressor", "_INFLIGHT_TASK_REPLAY_HEADER", INFLIGHT_REPLAY_HEADER)
+ return not after or after.startswith(replay)
+ return False
+
+
def is_summary(row: Any, prefixes: Iterable[str]) -> bool:
"""Return True for a summary record: the Hermes summary flag, or (the Hermes session store drops the flag) the
- whole carrier: a known summary prefix with the end marker, or the plugin header row. A user message that only
- starts with a prefix is a real request."""
+ whole carrier: a known summary prefix and an end marker that ends it (_ends_carrier), or the plugin header row.
+ A user message that only starts with a prefix, or has the marker in its text, is a real request."""
if attr(row, "_compressed_summary"):
return True
text = plain_text(attr(row, "content")).strip()
for prefix in prefixes:
if prefix and text.startswith(prefix):
rest = text[len(prefix):].strip()
- if END_MARKER in rest or rest == HEADER_TEXT:
+ if rest == HEADER_TEXT or _ends_carrier(rest):
return True
return False