Hermes Agent context engine: the main model writes the compaction handoff on its cached prompt prefix
Send the trailing user rows in the warm request
Elevatormusic81073e13d6a6
diff --git a/tests/test_wc_warm.py b/tests/test_wc_warm.pyindex bace0ad..61a82b7 100644--- a/tests/test_wc_warm.py+++ b/tests/test_wc_warm.py@@ -107,10 +107,17 @@ class BuildRequestTest(unittest.TestCase):sent = capture["body"]["messages"]self.assertEqual(json.dumps(body["messages"][: len(sent)]), json.dumps(sent))self.assertEqual(body["messages"][len(sent):], [- wire_row(self.reply), wire_row(tool("c1", "r1")), {"role": "user", "content": INSTRUCTION}])+ wire_row(self.reply), wire_row(tool("c1", "r1")), wire_row(user("u3")),+ {"role": "user", "content": INSTRUCTION}])self.assertEqual((body["stream"], body["temperature"]), (False, 0.2))self.assertNotIn("stream_options", body)+ def test_sends_every_trailing_user_row(self):+ # The tail can keep only the newest of several user rows. The handoff must see the older ones too.+ self.messages = [*self.messages, user("u4 " + "x" * 5_000)]+ body = self.build(capture_for(self.rows, self.reply))+ self.assertEqual(body["messages"][-3:-1], [wire_row(user("u3")), wire_row(user("u4 " + "x" * 5_000))])+def test_refusal_codes(self):good = capture_for(self.rows, self.reply)cases = [diff --git a/warm_compaction/warm.py b/warm_compaction/warm.pyindex c800523..0b8f820 100644--- a/warm_compaction/warm.py+++ b/warm_compaction/warm.py@@ -161,10 +161,11 @@ def build_request(capture: dict[str, Any], messages: list, route: tuple, contextif body is None:raise WarmRefusal("settings_unsupported")check_settings(body)- new_rows, _trailing = split_history(capture, messages)+ new_rows, trailing = split_history(capture, messages)check_source(body, messages[: len(capture["digests"])])request = dict(body)- request["messages"] = [*body["messages"], *(wire_row(row) for row in new_rows),+ # Send the trailing user rows too: the tail can keep only the newest of them, and compaction removes the others.+ request["messages"] = [*body["messages"], *(wire_row(row) for row in (*new_rows, *trailing)),{"role": "user", "content": instruction}]request["stream"] = Falserequest.pop("stream_options", None)