Skip to content

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

Follow the Hermes middleware rules in the stand-in chain: a block returns without next_call

Elevatormusic4c565601045f
diff --git a/tests/test_wc_engine.py b/tests/test_wc_engine.py
index dc993cd..6c609b6 100644
--- a/tests/test_wc_engine.py
+++ b/tests/test_wc_engine.py
@@ -161,11 +161,11 @@ class EngineTest(unittest.TestCase):
def test_a_blocking_or_mocking_middleware_stops_the_warm_request(self):
def block(request=None, next_call=None, **context):
- raise PermissionError("policy")
+ return None # A policy middleware blocks by not calling next_call.
def mock(request=None, next_call=None, **context):
return SimpleNamespace(choices=[])
- for middleware, reason in ((block, "middleware_refused"), (mock, "middleware_changed_reply")):
+ for middleware, reason in ((block, "middleware_changed_reply"), (mock, "middleware_changed_reply")):
with self.subTest(reason):
wc_hermes_stub.EXECUTION_MIDDLEWARE[:] = [middleware]
self.post.calls.clear()
diff --git a/tests/wc_hermes_stub.py b/tests/wc_hermes_stub.py
index 8434b1e..dad1a65 100644
--- a/tests/wc_hermes_stub.py
+++ b/tests/wc_hermes_stub.py
@@ -105,13 +105,21 @@ EXECUTION_MIDDLEWARE = []
def run_llm_execution_middleware(request, next_call, **context):
- """The llm_execution chain of Hermes, without its failure reporting."""
+ """The llm_execution chain of Hermes 45871e10: a callback that raises before next_call is skipped."""
def call_at(index, payload):
if index >= len(EXECUTION_MIDDLEWARE):
return next_call(payload)
- return EXECUTION_MIDDLEWARE[index](
- request=payload, next_call=lambda new=None: call_at(index + 1, payload if new is None else new),
- **context)
+ called = []
+
+ def downstream(new=None):
+ called.append(True)
+ return call_at(index + 1, payload if new is None else new)
+ try:
+ return EXECUTION_MIDDLEWARE[index](request=payload, next_call=downstream, **context)
+ except Exception:
+ if called:
+ raise
+ return call_at(index + 1, payload)
return call_at(0, request)