{"repo":"NousResearch/hermes-agent","public_id":"47268","display_label":"Background review isolation and hindsight retain fixes","summary":"These issues and PRs address bugs where background review processes incorrectly shared session context with the main agent loop, and fix destructive or unsafe behavior in hindsight memory retention. The work involves isolating background review forks and replacing unsafe retain operations with safer alternatives.","subsystem":"agent","counts":{"members":5,"open_issues":0,"open_issues_distinct":0,"open_prs":0,"closed_issues":2,"merged_prs":1,"attempt_prs":2},"landed_fix":{"status":"merged_to_main","basis":"structural","pr":27190},"resolution":{"state":"unresolved","by":null},"freshness":{"state":"verified","last_verified_at":"2026-05-17T03:33:38+00:00","is_stale":false},"grouping":{"backbone":"STRUCTURAL_PARTIAL","link_density":0.33599999999999997},"fix_edges":[{"issue_number":55816,"pr_number":27190,"tier":"verified","basis":"superseded_ref","confidence":0.9,"recoverable_from_timeline":false}],"members":[{"kind":"issue","number":47268,"title":"[Bug]: Background review shares session context with main loop, causing premature stop (11-77 char responses)","url":null,"state":"closed"},{"kind":"issue","number":55816,"title":"fix(hindsight): hindsight_retain destructive overwrite, misleading description, and Background Review abuse","url":null,"state":"closed"},{"kind":"pr","number":27190,"title":"fix(run_agent): isolate background review fork from external memory plugins","url":null,"state":"merged","close_reason":{"category":"merged","implication":"superseded"},"merged":true,"is_fix_pr":true,"fix_tier":"verified","files_changed":["run_agent.py","tests/run_agent/test_background_review.py"],"fix_hunks":[{"file":"run_agent.py","hunks":["@@ -4386,6 +4386,21 @@ def _bg_review_auto_deny(command, description, **kwargs):\n                     # owns the loop and the agent-loop tools dispatch.\n                     if _parent_api_mode == \"codex_app_server\":\n                         _parent_api_mode = \"codex_responses\"\n+                    # skip_memory=True keeps the review fork from\n+                    # touching external memory plugins (honcho, mem0,\n+                    # supermemory, etc.).  Without it, the fork's\n+                    # __init__ rebuilds its own _memory_manager from\n+                    # config, scoped to the parent's session_id, and\n+                    # run_conversation() then leaks the harness prompt\n+                    # into the user's real memory namespace via three\n+                    # ingestion sites: on_turn_start (cadence + turn\n+                    # message), prefetch_all (recall query), and\n+                    # sync_all (harness prompt + review output recorded\n+                    # as a (user, assistant) turn pair).  Built-in\n+                    # MEMORY.md / USER.md state is re-bound from the\n+                    # parent below so memory(action=\"add\") writes from\n+                    # the review still land on disk; the review just\n+                    # has zero side effects on external providers.\n                     review_agent = AIAgent(\n                         model=self.model,\n                         max_iterations=16,","@@ -4397,6 +4412,7 @@ def _bg_review_auto_deny(command, description, **kwargs):\n                         api_key=[redacted:secret-assignment]\"api_key\") or None,\n                         credential_pool=[redacted:secret-assignment] \"_credential_pool\", None),\n                         parent_session_id=self.session_id,\n+                        skip_memory=True,\n                     )\n                     review_agent._memory_write_origin = \"background_review\"\n                     review_agent._memory_write_context = \"background_review\""]},{"file":"tests/run_agent/test_background_review.py","hunks":["@@ -193,3 +193,51 @@ def close(self):\n     assert captured_bg_callback[0].startswith(\"💾 Self-improvement review:\"), (\n         captured_bg_callback[0]\n     )\n+\n+\n+def test_background_review_fork_skips_external_memory_plugins(monkeypatch):\n+    \"\"\"The background review fork must NOT touch external memory plugins.\n+\n+    Without skip_memory=True on the fork constructor, AIAgent.__init__\n+    rebuilds its own _memory_manager from config, scoped to the parent's\n+    session_id.  The review fork's run_conversation() then leaks the\n+    harness prompt into the user's real memory namespace via three\n+    ingestion sites: on_turn_start (cadence + turn message),\n+    prefetch_all (recall query), and sync_all (harness prompt + review\n+    output recorded as a (user, assistant) turn pair).  The fix is a\n+    single kwarg on the fork constructor — this test guards it.\n+    \"\"\"\n+    captured_kwargs: dict = {}\n+\n+    class FakeReviewAgent:\n+        def __init__(self, **kwargs):\n+            captured_kwargs.update(kwargs)\n+            self._session_messages = []\n+\n+        def run_conversation(self, **kwargs):\n+            pass\n+\n+        def shutdown_memory_provider(self):\n+            pass\n+\n+        def close(self):\n+            pass\n+\n+    monkeypatch.setattr(run_agent_module, \"AIAgent\", FakeReviewAgent)\n+    monkeypatch.setattr(run_agent_module.threading, \"Thread\", ImmediateThread)\n+\n+    agent = _bare_agent()\n+\n+    AIAgent._spawn_background_review(\n+        agent,\n+        messages_snapshot=[{\"role\": \"user\", \"content\": \"hello\"}],\n+        review_memory=True,\n+    )\n+\n+    assert captured_kwargs.get(\"skip_memory\") is True, (\n+        \"Background review fork must be constructed with skip_memory=True \"\n+        \"so AIAgent.__init__ does not rebuild a _memory_manager wired to \"\n+        \"external plugins (honcho, mem0, supermemory, ...).  Without this \"\n+        \"the fork leaks harness prompts into the user's real memory \"\n+        \"namespace via on_turn_start / prefetch_all / sync_all.\"\n+    )\n"]}]},{"kind":"pr","number":47364,"title":"fix(agent): stop bg-review from sharing parent session_id (#47268)","url":null,"state":"closed","close_reason":{"refs":[{"kind":"pr","value":"#47268","number":47268}],"category":"uncategorized","implication":"needs_llm"},"merged":false},{"kind":"pr","number":55819,"title":"fix(hindsight): replace destructive aretain_batch with safe file-based retain","url":null,"state":"closed","close_reason":{"refs":[{"kind":"commit","value":"4ece521bcf37401686e73f1d08ebaa87caaae05a","number":0},{"kind":"pr","value":"#27190","number":27190}],"category":"implemented_elsewhere","implication":"superseded"},"merged":false}],"trust":{"default_tier":"verified","includes_suggested":false}}