Skip to content

The agent that grows with you

chore: reconcile main's retired-lane follow-ups after the merge

teknium18637219a952f
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index 54e073a7642..104bf7b4e32 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -11129,11 +11129,11 @@ function resetHermesConnection({ soft = false } = {}) {
}
}
-// Every deliberate emptying of the primary slot goes through here so the
-// dying child's stale exit reads as intentional (see primaryRecoverySuppressed).
+// Every deliberate emptying of the primary slot goes through here. Main's
+// #112344 exit supervisor (respawn when a Desktop-owned child dies) has no
+// counterpart on the canonical path: the gateway owns its own lifetime and
+// this slot only caches its descriptor, so forgetting it just forces a re-dial.
function invalidatePrimaryConnection() {
- primaryRecoverySuppressed = true
-
return backendConnectionState.invalidate()
}
diff --git a/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx b/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx
index ecf0f418bcf..afff3498aa0 100644
--- a/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx
+++ b/apps/desktop/src/plugins/hermes-bots/bot-row.test.tsx
@@ -229,7 +229,7 @@ describe('the bot row context menu speaks the active language', () => {
describe('a group row', () => {
const members = [{ name: 'alpha' }, { name: 'beta' }, { name: 'gamma' }] as GroupMember[]
- const row = <GroupRow active={false} group="crew" members={members} needsYou={false} onDisband={noop} onOpen={noop} />
+ const row = <GroupRow active={false} group="crew" members={members} needsYou={false} onDisband={noop} onNewSection={noop} onOpen={noop} />
beforeEach(() => {
locale.current = 'en'
diff --git a/cli.py b/cli.py
index 457715ac658..55312ec345a 100644
--- a/cli.py
+++ b/cli.py
@@ -4134,13 +4134,10 @@ def _run_quiet_single_query(cli, effective_query, emitter=None):
from agent.interrupt_compat import _accepts_keyword
from agent.turn_author import take_turn_author_from_env
from hermes_cli.quiet_single_query import (
- adopt_unanswered_turn, bind_quiet_session_key, continue_quiet_notify_completions,
- quiet_notify_linger_seconds,
+ bind_quiet_session_key, continue_quiet_notify_completions, quiet_notify_linger_seconds,
)
author = take_turn_author_from_env()
- # A dispatcher's re-run of a failed bot delivery resumes the DM row its first attempt persisted.
- adopt_unanswered_turn(cli, effective_query)
author_kwargs = {"turn_author": author} if author is not None and _accepts_keyword(cli.agent.run_conversation, "turn_author") else {}
with bind_quiet_session_key(getattr(cli, "session_id", "") or "default"):
try:
diff --git a/hermes_cli/quiet_single_query.py b/hermes_cli/quiet_single_query.py
index a228da6b014..e4fe77bdb0a 100644
--- a/hermes_cli/quiet_single_query.py
+++ b/hermes_cli/quiet_single_query.py
@@ -92,43 +92,3 @@ def continue_quiet_notify_completions(
if not texts:
return last
return last
-
-
-def adopt_unanswered_turn(cli: Any, query: Any, environ: MutableMapping[str, str] = os.environ) -> bool:
- """A dispatcher's re-run of a failed delivery turn resumes the DM its first attempt already
- persisted instead of appending it again. Returns True when the tail row was adopted.
-
- The failed attempt's turn-start persist left the DM as the transcript's unanswered tail row. A
- fresh process cannot know that by itself (``_DB_PERSISTED_MARKER`` is in-process only), and
- inferring it from an identical tail alone would swallow a person's deliberate re-send — so the
- dispatcher must say so with ``tools.bot_relay.RESUME_UNANSWERED_TURN_ENV``, consumed (popped) here
- before the turn so tool subprocesses never inherit it. The row is re-staged as the pending CLI
- dict already stamped durable: ``_stage_turn_user_message`` reuses it as this turn's user message and
- the flush writes no second row.
-
- The DM is not always the literal tail: a turn that died mid-way (HTTP 503 on the call after a tool
- round) persisted its tool scaffolding — assistant ``tool_calls`` rows and their ``tool`` results —
- behind the DM before ``agent.turn_recovery`` built the failure text, and the dispatcher retries that
- too. The DM is still unanswered while nothing after it is a plain assistant reply, so it is adopted
- and the failed attempt's scaffolding leaves the in-memory transcript: the re-run starts the turn
- over from the DM (the rows stay in the DB as the record of the failed attempt; the re-run's answer
- lands after them as a valid continuation)."""
- from tools.bot_relay import RESUME_UNANSWERED_TURN_ENV
-
- if environ.pop(RESUME_UNANSWERED_TURN_ENV, None) != "1":
- return False
- history = getattr(cli, "conversation_history", None) or []
- idx = next((i for i in range(len(history) - 1, -1, -1)
- if isinstance(history[i], dict) and history[i].get("role") == "user"), None)
- if idx is None or history[idx].get("content") != query:
- return False
- if not all(isinstance(row, dict) and (row.get("role") == "tool" or (row.get("role") == "assistant" and row.get("tool_calls")))
- for row in history[idx + 1:]):
- return False
- from agent.context_compressor import _DB_PERSISTED_MARKER
-
- tail = history[idx]
- del history[idx:]
- tail[_DB_PERSISTED_MARKER] = True
- cli.agent._pending_cli_user_message = tail
- return True
diff --git a/tests/hermes_cli/test_quiet_single_query.py b/tests/hermes_cli/test_quiet_single_query.py
deleted file mode 100644
index aafba310296..00000000000
--- a/tests/hermes_cli/test_quiet_single_query.py
+++ /dev/null
@@ -1,78 +0,0 @@
-"""``hermes chat -Q`` as a dispatcher's re-run of a failed bot delivery (#111721).
-
-A failed delivery turn persists its user row before the provider call; the policy-gated re-run
-replays the same session and payload in a fresh process. Told so via HERMES_RESUME_UNANSWERED_TURN,
-the re-run resumes that row instead of appending a second copy of the DM.
-"""
-
-from __future__ import annotations
-
-import os
-from types import SimpleNamespace
-
-import cli
-from agent.context_compressor import _DB_PERSISTED_MARKER
-from tools.bot_relay import RESUME_UNANSWERED_TURN_ENV
-
-
-def _quiet_turn(monkeypatch, history, marker):
- monkeypatch.delenv("HERMES_KANBAN_GOAL_MODE", raising=False)
- monkeypatch.delenv("HERMES_KANBAN_TASK", raising=False)
- if marker is None:
- monkeypatch.delenv(RESUME_UNANSWERED_TURN_ENV, raising=False)
- else:
- monkeypatch.setenv(RESUME_UNANSWERED_TURN_ENV, marker)
- seen = {}
-
- def run_conversation(**kwargs):
- seen["history"] = list(kwargs["conversation_history"])
- seen["env"] = os.environ.get(RESUME_UNANSWERED_TURN_ENV)
- return {"final_response": "ok"}
-
- agent = SimpleNamespace(run_conversation=run_conversation, session_id="s-1")
- the_cli = SimpleNamespace(agent=agent, conversation_history=history, session_id="s-1")
- try:
- cli._run_quiet_single_query(the_cli, "hello")
- except SystemExit as exc:
- assert exc.code == 0
- return agent, seen
-
-
-def test_rerun_resumes_the_unanswered_user_row_it_already_persisted(monkeypatch):
- tail = {"role": "user", "content": "hello"}
- agent, seen = _quiet_turn(monkeypatch, [{"role": "assistant", "content": "earlier"}, tail], "1")
- # The persisted row leaves the history and becomes this turn's staged user dict, already
- # durable — so the agent reuses it as the turn's user message and the flush writes no new row.
- assert seen["history"] == [{"role": "assistant", "content": "earlier"}]
- assert agent._pending_cli_user_message is tail
- assert tail[_DB_PERSISTED_MARKER] is True
- assert seen["env"] is None, "the marker is consumed before the turn so tool subprocesses never inherit it"
-
-
-def test_without_the_marker_or_an_unanswered_tail_nothing_is_adopted(monkeypatch):
- """A person re-sending the same word after a failed turn has sent a second real message; an
- answered tail is not a re-run either. Only the dispatcher's explicit marker plus an identical
- unanswered tail adopts a row."""
- tail = {"role": "user", "content": "hello"}
- agent, seen = _quiet_turn(monkeypatch, [tail], None)
- assert seen["history"] == [tail] and not hasattr(agent, "_pending_cli_user_message")
- assert _DB_PERSISTED_MARKER not in tail
-
- answered = [{"role": "user", "content": "hello"}, {"role": "assistant", "content": "done"}]
- agent, seen = _quiet_turn(monkeypatch, list(answered), "1")
- assert seen["history"] == answered and not hasattr(agent, "_pending_cli_user_message")
-
-
-def test_rerun_adopts_the_dm_behind_the_failed_attempts_tool_scaffolding(monkeypatch):
- """A 503 after a tool round persisted user + assistant(tool_calls) + tool before the failure text,
- and the dispatcher retries it. The DM is still unanswered: the re-run adopts it and drops the
- failed attempt's scaffolding from the in-memory turn instead of appending a second copy."""
- tail = {"role": "user", "content": "hello"}
- scaffolding = [
- {"role": "assistant", "content": None, "tool_calls": [{"id": "c1", "type": "function",
- "function": {"name": "t", "arguments": "{}"}}]},
- {"role": "tool", "tool_call_id": "c1", "content": "result"},
- ]
- agent, seen = _quiet_turn(monkeypatch, [{"role": "assistant", "content": "earlier"}, tail, *scaffolding], "1")
- assert seen["history"] == [{"role": "assistant", "content": "earlier"}]
- assert agent._pending_cli_user_message is tail and tail[_DB_PERSISTED_MARKER] is True