The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
Revert "fix(cli): chat -q approvals keep the approvals.timeout deadline"
teknium1e028d0fddb0b
diff --git a/hermes_cli/cli_chat_turn_mixin.py b/hermes_cli/cli_chat_turn_mixin.pyindex 5961d86ecce..c8b8dcb5e53 100644--- a/hermes_cli/cli_chat_turn_mixin.py+++ b/hermes_cli/cli_chat_turn_mixin.py@@ -346,10 +346,8 @@ class CLIChatTurnMixin:_one_turn_model_restore = getattr(self, "_pending_one_turn_model_restore", None)self._pending_one_turn_model_restore = None# The user is at this terminal: approval and clarify prompts wait until answered or Ctrl+C.- # `chat -q` has nobody to answer (no prompt_toolkit app, often no stdin), so it keeps the- # approvals.timeout deadline instead of waiting forever.from tools.approval_context import reset_prompts_wait_for_answer, set_prompts_wait_for_answer- _prompts_token = None if getattr(self, "_single_query_mode", False) else set_prompts_wait_for_answer()+ _prompts_token = set_prompts_wait_for_answer()try:from agent.notification_presentation import notification_turnmuted = getattr(turn, "mute_notification_reply", False)@@ -400,8 +398,7 @@ class CLIChatTurnMixin:reset_current_session_key(_approval_session_token)except Exception:pass- if _prompts_token is not None:- reset_prompts_wait_for_answer(_prompts_token)+ reset_prompts_wait_for_answer(_prompts_token)def _chat_monitor_agent_thread(self, turn, agent_thread):"""Poll the interrupt queue while the agent thread runs; returns the interrupting message (or None)."""diff --git a/hermes_cli/cli_modal_mixin.py b/hermes_cli/cli_modal_mixin.pyindex 7be35cad9b1..f460db6c616 100644--- a/hermes_cli/cli_modal_mixin.py+++ b/hermes_cli/cli_modal_mixin.py@@ -1050,10 +1050,9 @@ class CLIModalMixin:"""Dangerous-command approval through the prompt_toolkit UI (agent thread).Choices: once / session / always / deny (see ``_approval_choices``), plus 'view' for long- commands. The panel stays up until the user answers (Ctrl+C interrupts the turn), except in- ``chat -q``: no prompt_toolkit app can answer there, so it keeps the ``approvals.timeout``- deadline and returns ``"timeout"``. ``_approval_lock`` serializes concurrent requests- (parallel delegation subtasks) so the shared ``_approval_state`` isn't clobbered.+ commands. The panel stays up until the user answers (Ctrl+C interrupts the turn).+ ``_approval_lock`` serializes concurrent requests (parallel delegation subtasks) so the+ shared ``_approval_state`` isn't clobbered."""with self._approval_lock:response_queue = queue.Queue()@@ -1068,9 +1067,6 @@ class CLIModalMixin:"selected": 0,"response_queue": response_queue}self._approval_deadline = None- if getattr(self, "_single_query_mode", False):- from tools.approval_context import approval_wait_seconds- self._approval_deadline = _time.monotonic() + approval_wait_seconds()self._ring_bell(prompt=True, context=t("cli.approval.bell_context"), detail=command)self._paint_now()@@ -1078,12 +1074,6 @@ class CLIModalMixin:self._approval_state = Noneself._approval_deadline = 0self._paint_now()- if result is _TIMED_OUT:- from cli import _DIM, _RST, _cprint- _cprint(f"\n{_DIM} {t('cli.approval.timeout_denying')}{_RST}")- self._persist_prompt_summary(- "⚠", t("cli.approval.label"), command, t("cli.approval.timed_out_no_response"))- return "timeout"self._persist_prompt_summary("⚠", t("cli.approval.label"), command, _approval_outcome_label(result))return resultdiff --git a/locales/af.yaml b/locales/af.yamlindex bc585ed2b57..bc41ef21bb2 100644--- a/locales/af.yaml+++ b/locales/af.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "goedkeuring"label: "Goedkeuring"- timeout_denying: "⏱ Tyd verstreke — opdrag word geweier"- timed_out_no_response: "tyd verstreke (geen antwoord)"outcome_once: "eenmalig toegelaat"outcome_session: "vir sessie toegelaat"outcome_always: "by toelaatlys gevoeg"diff --git a/locales/ar.yaml b/locales/ar.yamlindex 830b57d4f0f..61727f72b8c 100644--- a/locales/ar.yaml+++ b/locales/ar.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "الموافقة"label: "الموافقة"- timeout_denying: "⏱ انتهت المهلة — رفض الأمر"- timed_out_no_response: "انتهت المهلة (لا استجابة)"outcome_once: "مسموح مرة واحدة"outcome_session: "مسموح لهذه الجلسة"outcome_always: "أُضيف إلى قائمة السماح"diff --git a/locales/de.yaml b/locales/de.yamlindex b481d18cbf4..53a398be048 100644--- a/locales/de.yaml+++ b/locales/de.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "Genehmigung"label: "Genehmigung"- timeout_denying: "⏱ Zeitüberschreitung — Befehl wird abgelehnt"- timed_out_no_response: "Zeitüberschreitung (keine Antwort)"outcome_once: "einmalig erlaubt"outcome_session: "für diese Sitzung erlaubt"outcome_always: "zur Erlaubnisliste hinzugefügt"diff --git a/locales/en.yaml b/locales/en.yamlindex 032b7d4acd0..17fd5c5e6c2 100644--- a/locales/en.yaml+++ b/locales/en.yaml@@ -2352,8 +2352,6 @@ cli:approval:bell_context: "approval"label: "Approval"- timeout_denying: "⏱ Timeout — denying command"- timed_out_no_response: "timed out (no response)"outcome_once: "allowed once"outcome_session: "allowed for session"outcome_always: "added to allowlist"diff --git a/locales/es.yaml b/locales/es.yamlindex 60a9b7bbf33..79dd57e681d 100644--- a/locales/es.yaml+++ b/locales/es.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "aprobación"label: "Aprobación"- timeout_denying: "⏱ Tiempo agotado — denegando el comando"- timed_out_no_response: "tiempo agotado (sin respuesta)"outcome_once: "permitido una vez"outcome_session: "permitido para la sesión"outcome_always: "añadido a la lista de permitidos"diff --git a/locales/fr.yaml b/locales/fr.yamlindex 88b2308916c..defd1f66011 100644--- a/locales/fr.yaml+++ b/locales/fr.yaml@@ -2525,8 +2525,6 @@ cli:approval:bell_context: "approbation"label: "Approbation"- timeout_denying: "⏱ Délai dépassé — commande refusée"- timed_out_no_response: "délai dépassé (aucune réponse)"outcome_once: "autorisé une fois"outcome_session: "autorisé pour la session"outcome_always: "ajouté à la liste d'autorisation"diff --git a/locales/ga.yaml b/locales/ga.yamlindex c461efe2e7e..eb77a1a0d57 100644--- a/locales/ga.yaml+++ b/locales/ga.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "cead"label: "Cead"- timeout_denying: "⏱ Teorainn ama — ag diúltú don ordú"- timed_out_no_response: "imithe thar am (gan freagra)"outcome_once: "ceadaithe uair amháin"outcome_session: "ceadaithe don seisiún"outcome_always: "curtha leis an liosta ceadaithe"diff --git a/locales/hu.yaml b/locales/hu.yamlindex c5da94731b5..ed1a4932189 100644--- a/locales/hu.yaml+++ b/locales/hu.yaml@@ -2269,8 +2269,6 @@ cli:approval:bell_context: "jóváhagyás"label: "Jóváhagyás"- timeout_denying: "⏱ Időtúllépés — a parancs elutasítva"- timed_out_no_response: "időtúllépés (nem jött válasz)"outcome_once: "egyszer engedélyezve"outcome_session: "a munkamenetre engedélyezve"outcome_always: "engedélyezőlistára téve"diff --git a/locales/it.yaml b/locales/it.yamlindex ca6ea5aca48..b3f03925ce7 100644--- a/locales/it.yaml+++ b/locales/it.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "approvazione"label: "Approvazione"- timeout_denying: "⏱ Timeout — comando negato"- timed_out_no_response: "timeout (nessuna risposta)"outcome_once: "consentito una volta"outcome_session: "consentito per la sessione"outcome_always: "aggiunto alla allowlist"diff --git a/locales/ja.yaml b/locales/ja.yamlindex 80c9f28404a..77a36ae1152 100644--- a/locales/ja.yaml+++ b/locales/ja.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "承認"label: "承認"- timeout_denying: "⏱ タイムアウト — コマンドを拒否します"- timed_out_no_response: "タイムアウト(応答なし)"outcome_once: "今回のみ許可"outcome_session: "セッション中は許可"outcome_always: "許可リストに追加"diff --git a/locales/ko.yaml b/locales/ko.yamlindex 90bcda75282..4ad97b76c55 100644--- a/locales/ko.yaml+++ b/locales/ko.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "승인"label: "승인"- timeout_denying: "⏱ 시간 초과 — 명령을 거부해요"- timed_out_no_response: "시간 초과 (응답 없음)"outcome_once: "한 번 허용됨"outcome_session: "세션 동안 허용됨"outcome_always: "허용 목록에 추가됨"diff --git a/locales/pt.yaml b/locales/pt.yamlindex 604b0aef611..b6b04043cf1 100644--- a/locales/pt.yaml+++ b/locales/pt.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "aprovação"label: "Aprovação"- timeout_denying: "⏱ Tempo limite — negando o comando"- timed_out_no_response: "tempo limite esgotado (sem resposta)"outcome_once: "permitido uma vez"outcome_session: "permitido para a sessão"outcome_always: "adicionado à lista de permissões"diff --git a/locales/ru.yaml b/locales/ru.yamlindex b9594b8f845..a97cf5aadc1 100644--- a/locales/ru.yaml+++ b/locales/ru.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "одобрение"label: "Одобрение"- timeout_denying: "⏱ Тайм-аут — команда отклонена"- timed_out_no_response: "тайм-аут (нет ответа)"outcome_once: "разрешено один раз"outcome_session: "разрешено на сеанс"outcome_always: "добавлено в список разрешённых"diff --git a/locales/tr.yaml b/locales/tr.yamlindex 1cd00ba50e5..989c8bcd941 100644--- a/locales/tr.yaml+++ b/locales/tr.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "onay"label: "Onay"- timeout_denying: "⏱ Zaman aşımı — komut reddediliyor"- timed_out_no_response: "zaman aşımı (yanıt yok)"outcome_once: "bir kez izin verildi"outcome_session: "oturum için izin verildi"outcome_always: "izin listesine eklendi"diff --git a/locales/uk.yaml b/locales/uk.yamlindex 976e4a1c9f6..b764c3db259 100644--- a/locales/uk.yaml+++ b/locales/uk.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "схвалення"label: "Схвалення"- timeout_denying: "⏱ Час вийшов — команду відхилено"- timed_out_no_response: "час вийшов (без відповіді)"outcome_once: "дозволено один раз"outcome_session: "дозволено для сеансу"outcome_always: "додано до списку дозволених"diff --git a/locales/zh-hant.yaml b/locales/zh-hant.yamlindex 732ef48c31e..f3b12c8f310 100644--- a/locales/zh-hant.yaml+++ b/locales/zh-hant.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "批准"label: "批准"- timeout_denying: "⏱ 逾時 — 拒絕指令"- timed_out_no_response: "已逾時(無回應)"outcome_once: "允許一次"outcome_session: "本工作階段允許"outcome_always: "已加入允許清單"diff --git a/locales/zh.yaml b/locales/zh.yamlindex e86cdc9339e..dcdd9913000 100644--- a/locales/zh.yaml+++ b/locales/zh.yaml@@ -2252,8 +2252,6 @@ cli:approval:bell_context: "审批"label: "审批"- timeout_denying: "⏱ 超时——拒绝执行命令"- timed_out_no_response: "已超时(无响应)"outcome_once: "已允许一次"outcome_session: "本会话内已允许"outcome_always: "已加入允许列表"diff --git a/tests/hermes_cli/test_cli_approval_ui.py b/tests/hermes_cli/test_cli_approval_ui.pyindex 4efc753b624..a7ee0071b33 100644--- a/tests/hermes_cli/test_cli_approval_ui.py+++ b/tests/hermes_cli/test_cli_approval_ui.py@@ -91,18 +91,6 @@ class TestCliApprovalUi:thread.join(timeout=2)assert result["value"] == "once"- def test_single_query_panel_times_out_at_approvals_timeout(self):- """``chat -q`` has no prompt_toolkit app to answer the panel: it denies at- ``approvals.timeout`` instead of parking the turn until the safe maximum."""- cli = _make_cli_stub()- cli._single_query_mode = True- cli._persist_prompt_summary = MagicMock()- with patch("tools.approval_context.approval_wait_seconds", return_value=1):- started = time.monotonic()- assert cli._approval_callback("rm -rf /tmp/x", "delete") == "timeout"- assert time.monotonic() - started < 5- assert cli._approval_state is None-def test_smart_denied_callback_offers_only_once_and_deny(self):cli = _make_cli_stub()result = {}diff --git a/tests/hermes_cli/test_cli_single_query_prompt_window.py b/tests/hermes_cli/test_cli_single_query_prompt_window.pydeleted file mode 100644index 7c6ecbe99a2..00000000000--- a/tests/hermes_cli/test_cli_single_query_prompt_window.py+++ /dev/null@@ -1,39 +0,0 @@-"""`chat -q` has nobody at a prompt: its turn must not bind the wait-until-answered policy.--The interactive CLI binds ``set_prompts_wait_for_answer()`` around each turn so approval panels stay-up until answered. A single-query turn has no prompt_toolkit app (and often no stdin), so binding it-there parks every approval for ``MAX_SAFE_TIMEOUT_S`` instead of ``approvals.timeout``.-"""--from __future__ import annotations--from types import SimpleNamespace-from unittest.mock import Mock--import pytest--from cli import HermesCLI, _ChatTurn-from tools.approval_context import prompts_wait_for_answer---def _run_turn(single_query: bool) -> bool:- cli = HermesCLI.__new__(HermesCLI)- cli.session_id = "prompt-window"- cli.conversation_history = [{"role": "user", "content": "go"}]- if single_query:- setattr(cli, "_single_query_mode", True)- seen = {}-- def _run_conversation(**_kwargs):- seen["wait_for_answer"] = prompts_wait_for_answer()- return {}-- cli.agent = SimpleNamespace(run_conversation=Mock(side_effect=_run_conversation))- cli._chat_run_agent(_ChatTurn(), "go")- assert prompts_wait_for_answer() is False, "turn leaked the wait-for-answer binding"- return seen["wait_for_answer"]--[email protected](("single_query", "expected"), [(False, True), (True, False)])-def test_only_an_attended_turn_waits_for_an_answer(single_query, expected):- assert _run_turn(single_query) is expected