Skip to content

The agent that grows with you

fix(cli): /bg turns hold their prompts open like the foreground turn

Brooklyn Nicholson553bd72f33ea
diff --git a/hermes_cli/cli_commands_mixin.py b/hermes_cli/cli_commands_mixin.py
index a1ed54c9b42..506038fde37 100644
--- a/hermes_cli/cli_commands_mixin.py
+++ b/hermes_cli/cli_commands_mixin.py
@@ -1987,6 +1987,9 @@ class CLICommandsMixin:
self._app.invalidate()
bg_agent.thinking_callback = _bg_thinking
+ # /bg prompts paint on this terminal: they wait until answered, like the foreground turn's.
+ from tools.approval_context import reset_prompts_wait_for_answer, set_prompts_wait_for_answer
+ prompts_token = set_prompts_wait_for_answer()
try:
result = bg_agent.run_conversation(user_message=prompt, task_id=task_id)
response = result.get("final_response", "") if result else ""
@@ -1994,6 +1997,7 @@ class CLICommandsMixin:
response = _gt("model.error_prefix", error=result["error"])
return response
finally:
+ reset_prompts_wait_for_answer(prompts_token)
# One agent per /bg task in a long-lived CLI process: close()
# is the owner boundary (memory shutdown, tool subprocesses,
# httpx clients); an unclosed side agent leaks all of them
diff --git a/tests/hermes_cli/test_cli_approval_ui.py b/tests/hermes_cli/test_cli_approval_ui.py
index b015dc96e73..a7ee0071b33 100644
--- a/tests/hermes_cli/test_cli_approval_ui.py
+++ b/tests/hermes_cli/test_cli_approval_ui.py
@@ -7,6 +7,7 @@ from unittest.mock import MagicMock, patch
import cli as cli_module
from agent.i18n import t
from cli import HermesCLI
+from tools import approval_context
class _FakeBuffer:
@@ -261,6 +262,7 @@ class TestCliApprovalUi:
seen["approval"] = _get_approval_callback()
seen["sudo"] = _get_sudo_password_callback()
+ seen["approval_wait"] = approval_context.approval_wait_seconds()
return {
"final_response": "done",
"messages": [],
@@ -269,6 +271,7 @@ class TestCliApprovalUi:
}
with patch("run_agent.AIAgent", FakeAgent), \
+ patch.object(approval_context, "_get_approval_config", lambda: {"timeout": 1}), \
patch.object(cli_module, "_cprint"), \
patch.object(cli_module, "ChatConsole") as chat_console:
chat_console.return_value.print = MagicMock()
@@ -284,6 +287,8 @@ class TestCliApprovalUi:
assert seen["approval"].__func__ is HermesCLI._approval_callback
assert seen["sudo"].__self__ is cli
assert seen["sudo"].__func__ is HermesCLI._sudo_password_callback
+ # The panel waits until answered, so the turn's accounting must too (not approvals.timeout).
+ assert seen["approval_wait"] > 1
assert not cli._background_tasks