The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(state): preserve replies after consecutive review harness prompts
KoNit-K6a8862404d1c
diff --git a/hermes_state.py b/hermes_state.pyindex 87b143017c4..21a39dae613 100644--- a/hermes_state.py+++ b/hermes_state.py@@ -298,14 +298,20 @@ def _strip_background_review_harness(messages: List[Dict[str, Any]]) -> List[Dicreturn messagesout: List[Dict[str, Any]] = []skip_next_assistant = False+ previous_was_harness = Falsefor msg in messages:if _is_background_review_harness_message(msg):- skip_next_assistant = True+ # A consecutive harness prompt occupies the preceding prompt's+ # immediate reply slot, so it must not arm another assistant skip.+ skip_next_assistant = not previous_was_harness+ previous_was_harness = Truecontinueif skip_next_assistant:skip_next_assistant = Falseif isinstance(msg, dict) and msg.get("role") == "assistant":+ previous_was_harness = Falsecontinue # the curator-mode reply to the harness prompt+ previous_was_harness = Falseout.append(msg)return outdiff --git a/tests/hermes_state/test_background_review_session_isolation.py b/tests/hermes_state/test_background_review_session_isolation.pyindex fb560d7e4e5..57dcbfb209c 100644--- a/tests/hermes_state/test_background_review_session_isolation.py+++ b/tests/hermes_state/test_background_review_session_isolation.py@@ -53,6 +53,15 @@ class TestStripBackgroundReviewHarness:contents = [m["content"] for m in out]assert contents == ["What's the weather?", "It's sunny.", "Thanks, now book a flight."]+ def test_preserves_assistant_after_consecutive_harness_prompts(self):+ messages = [+ {"role": "user", "content": "Review the conversation above and update the skill library."},+ {"role": "user", "content": "Review the conversation above and consider saving to memory."},+ {"role": "assistant", "content": "The user's real reply."},+ ]++ assert _strip_background_review_harness(messages) == [messages[-1]]+