The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cli): quiet -Q notify loop must not drop owned async_delegation events
kshitijk4poord503526b8049
diff --git a/hermes_cli/quiet_single_query.py b/hermes_cli/quiet_single_query.pyindex c1508a99380..a31bfa9ee10 100644--- a/hermes_cli/quiet_single_query.py+++ b/hermes_cli/quiet_single_query.py@@ -63,10 +63,11 @@ def continue_quiet_notify_completions(for _ in range(max_rounds):wait = process_registry.wait_for_pending_completions(None, timeout=max(deadline - time.monotonic(), 0.0))drained = process_registry.drain_notifications(session_key=key, owns_event=owns_event)- texts = [- text for event, text in drained- if event.get("type", "completion") == "completion" and text- ]+ # Every drained event type carries formatted text (completions, watch matches,+ # async_delegation results): drain_notifications POPS owned events off the queue,+ # so filtering by type here would consume-and-silently-drop owned+ # async_delegation results. Keep everything that rendered.+ texts = [text for _event, text in drained if text]if texts:last = run_turn("\n\n".join(texts))if wait.get("timed_out"):diff --git a/tests/hermes_cli/test_quiet_turn_author.py b/tests/hermes_cli/test_quiet_turn_author.pyindex d5608d60010..d7368a43aad 100644--- a/tests/hermes_cli/test_quiet_turn_author.py+++ b/tests/hermes_cli/test_quiet_turn_author.py@@ -135,3 +135,31 @@ def test_quiet_notify_loop_shares_one_linger_budget(monkeypatch):assert waits == [600.0]assert calls == []assert result is None+++def test_quiet_notify_loop_injects_owned_async_delegation_events(monkeypatch):+ """Owned async_delegation results must not be consumed-and-dropped by the loop.++ drain_notifications pops owned events of every type; the quiet loop is this+ one-shot's only consumer, so an owned async_delegation text is injected as a+ follow-up turn exactly like a completion.+ """+ from hermes_cli import quiet_single_query as qsq+ from tools import process_registry as pr++ monkeypatch.setattr(pr.process_registry, "wait_for_pending_completions",+ lambda *a, **k: {"waited": [], "completed": [], "timed_out": []})+ # A real drain pops owned events; round 2 finds the queue empty and the loop returns.+ events = [({"type": "async_delegation", "session_key": "session-B"}, "[IMPORTANT: delegated reply from C]")]++ def fake_drain(*a, **k):+ return [events.pop(0)] if events else []++ monkeypatch.setattr(pr.process_registry, "drain_notifications", fake_drain)++ seen = []+ result = qsq.continue_quiet_notify_completions(+ "session-B", lambda text: seen.append(text) or {"final_response": text}, linger_budget=0.0,+ )+ assert seen == ["[IMPORTANT: delegated reply from C]"]+ assert result == {"final_response": "[IMPORTANT: delegated reply from C]"}