Skip to content

[Bug]: /clear, /new, /reset, /undo confirmation prompt cannot be answered — keystrokes leak into chat composer #22958

Closed as not planned

Description

@shermanwsmith

Bug Description

Version: 0.13.0
Platform: Linux

The destructive-slash confirmation prompt added to cli.py (_confirm_destructive_slash, around line 8362) renders correctly but its input intercept never fires. Typing the answer (1, 2, or 3) sends that character to the agent as a chat message instead of resolving the prompt.

Steps to Reproduce

  1. Start Hermes CLI in TUI mode (hermes chat).
  2. Type /clear (or /new, /reset, /undo).
  3. Confirmation prompt prints:
⚠   /clear — destroys conversation state

  This clears the screen and starts a new session.
  The current conversation history will be discarded.

  [1] Approve Once   — proceed this time only
  [2] Always Approve — proceed and silence this prompt permanently
  [3] Cancel         — keep current conversation
  1. Type 2 and press Enter.

Expected Behavior

prompt resolves, "Always Approve" path runs, approvals.destructive_slash_confirm is persisted to false.

Actual Behavior

the 2 is delivered to the agent as a user message ("2"). The prompt remains unresolved. The destructive command never runs and never cancels — it's just abandoned.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

No response

Debug Report

N/A, contains identifiable personal information due to machine setup

Operating System

Pop!OS 24.04

Python Version

3.11.15

Hermes Version

0.13.0

Additional Logs / Traceback (optional)

Root Cause Analysis (optional)

Most likely cause:
_prompt_text_input (cli.py:5860) calls Python's built-in input() from inside prompt_toolkit.application.run_in_terminal:

def _prompt_text_input(self, prompt_text: str) -> str | None:
    result = [None]
    def _ask():
        try:
            result[0] = input(prompt_text).strip() or None
        except (KeyboardInterrupt, EOFError):
            pass
    if self._app:
        from prompt_toolkit.application import run_in_terminal
        was_visible = self._status_bar_visible
        self._status_bar_visible = False
        self._app.invalidate()
        try:
            run_in_terminal(_ask)
        finally:
            self._status_bar_visible = was_visible
            self._app.invalidate()
    else:
        _ask()
    return result[0]

When the TUI Application is active, run_in_terminal is supposed to suspend the app's screen and hand stdin back to the wrapped callable. In this code path that handoff doesn't appear to happen — the prompt prints, but keystrokes continue to be consumed by prompt_toolkit's main input handler and end up in _pending_input, which process_loop then forwards to the agent as a normal user message. The result [None] is never populated, the prompt returns None, and _confirm_destructive_slash treats that as "cancelled (no input)", except the cancel message is also never printed because the function is sitting on input() that will never return.

May be related — same session as a broken-prompt repro shows these in ~/.hermes/logs/errors.log:

WARNING cli: process_loop unhandled error (msg may be lost):
There is no current event loop in thread 'Thread-3 (process_loop)'.

process_loop is the thread that drains _pending_input, so an asyncio-context bug there could plausibly interfere with run_in_terminal's stdin handoff. Not confirmed, just a correlation worth checking.

Proposed Fix (optional)

Replace the built-in input() in _prompt_text_input with prompt_toolkit's native prompt(), which cooperates with the active Application instead of competing for stdin:

def _prompt_text_input(self, prompt_text: str) -> str | None:
    if self._app:
        from prompt_toolkit.application import run_in_terminal
        from prompt_toolkit.shortcuts import prompt as pt_prompt
        result = [None]
        def _ask():
            try:
                raw = pt_prompt(prompt_text)
                result[0] = raw.strip() or None
            except (KeyboardInterrupt, EOFError):
                pass
        was_visible = self._status_bar_visible
        self._status_bar_visible = False
        self._app.invalidate()
        try:
            run_in_terminal(_ask)
        finally:
            self._status_bar_visible = was_visible
            self._app.invalidate()
        return result[0]
    # Non-TUI fallback unchanged
    try:
        return input(prompt_text).strip() or None
    except (KeyboardInterrupt, EOFError):
        return None

A more invasive but cleaner alternative: render the choice as a prompt_toolkit modal, similar to the /model picker at cli.py:5884 (_open_model_picker). That reuses the existing input-capture machinery and gets you arrow-key navigation for free, but it's a bigger change.

Workaround for affected users

Add to ~/.hermes/config.yaml:

  approvals:
    destructive_slash_confirm: false

This bypasses the prompt entirely (cli.py:8391–8392). Confirmed working on 0.13.0.

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Activity

  1. added
    type/bugSomething isn't working
    P1High — major feature broken, no workaround
    comp/cliCLI entry point, hermes_cli/, setup wizard
    on May 10, 2026
  2. misterjice commented on May 10, 2026

    @misterjice

    I'm having the same problem. Looks like we have a commit though; any idea when it will go live?

  3. shermanwsmith commented on May 10, 2026

    @shermanwsmith
    Author

    I'm having the same problem. Looks like we have a commit though; any idea when it will go live?

    if you want a workaround, use this:

      approvals:
        destructive_slash_confirm: false
    

    Place it in your config.yaml and it'll bypass that authentication pop until a fix is released.

  4. added a commit that references this issue on May 11, 2026
    5a4cdc1
  5. SoumyadeepDas commented on May 12, 2026

    @SoumyadeepDas

    Additional reproduction path: dangerous command permission prompt during delegate_task

    Same root cause as described here, but triggered differently.

    Setup: Main agent using delegate_task to spawn subagents in a
    multi-agent pipeline (Hermes 0.10.0, Linux).

    What happens: When a subagent encounters a dangerous command and
    triggers the permission prompt (Allow Once / Always Allow / Deny),
    the entire CLI freezes completely — not just the prompt, but all
    input. Nothing is accepted. The session has to be killed manually.

    This is broader than /new and /clear. Any dangerous command
    permission prompt raised from a subagent (daemon thread) triggers
    the same stdin deadlock. The user has no way to respond to the
    prompt or recover the session without killing the process.

    Environment: Hermes 0.10.0, Linux, Python 3.11, prompt_toolkit 3.x

    Workaround in use: Main agent falls back to executing blocked
    steps directly via subprocess when subagents are blocked, bypassing
    delegation entirely.

    Noting this so the fix in #22989/#22987 covers permission prompts
    from subagent daemon threads, not just destructive slash commands.

  6. tgmerritt commented on May 26, 2026

    @tgmerritt

    Confirmed in VS Code integrated terminal and in iTerm2 on Mac. I SSH into a separate system where hermes-agent runs.

    Steps to reproduce:

    1. Start a hermes session (via SSH from either iTerm2 or VS Code terminal)
    2. Type a slash command like /new, /clear, or /reset

    Expected: A confirmation prompt appears and the session resets.
    Actual: The screen never clears or resets. Everything freezes - pressing keys (characters, delete, spacebar) does not produce any visible output. The terminal becomes completely unresponsive and hangs permanently unless I right-click and kill/reset the terminal session.

    Environment:

    • Mac (local terminal)
    • iTerm2 and VS Code integrated terminal (via SSH to remote Linux host)
    • hermes-agent running on remote system via SSH
  7. LZX0719-Hub commented on May 28, 2026

    @LZX0719-Hub

    Same issue on WSL (Windows Subsystem for Linux)

    Confirmed on WSL 2 (Ubuntu) via Windows Terminal. The /reset and /new commands hang completely — the terminal becomes unresponsive and must be killed.

    Additional symptoms on WSL:

    • The agent log shows: [Errno 5] Input/output error — prompt_toolkit fails to write to stdout when rendering the confirmation modal, causing the process_loop to catch and log the error silently.
    • After the EIO error, the terminal environment is cleaned up but no prompt returns — the CLI appears dead.
    • The same issue occurs in VS Code integrated terminal (WSL remote) and Windows Terminal.

    Workarounds (confirmed working on WSL):

    1. Inline skip: /reset now or /new now bypasses the modal entirely.
    2. Config: Set approvals.destructive_slash_confirm: false in config.yaml.

    Environment details:

    • OS: Windows 11 + WSL 2 (Ubuntu)
    • Terminal: Windows Terminal / VS Code integrated terminal
    • Provider: opencode-go (deepseek-v4-flash)
    • Python: 3.14.4

    Would be great if the fix also covers cases where the terminal write fails with EIO at the prompt_toolkit level, so the confirmation gracefully falls back to simple input() or skips automatically.

  8. teknium1 commented on Jun 11, 2026

    @teknium1
    Collaborator

    This looks implemented on current main. Automated hermes-sweeper review found the destructive slash confirmation path no longer depends on raw input() while prompt_toolkit owns stdin.

    Evidence:

    • cli.py:8501 routes /clear, /new, /reset, and /undo confirmations through the prompt_toolkit-native _prompt_text_input_modal(...) path, then persists approvals.destructive_slash_confirm: false for the “Always Approve” choice at cli.py:8526.
    • cli.py:6298 implements the modal by creating _slash_confirm_state, scheduling setup onto self._app.loop.call_soon_threadsafe when invoked off the main thread, and waiting on a response queue instead of reading stdin directly.
    • cli.py:10979 handles Enter while _slash_confirm_state is active and returns before normal chat submission, so typed 1/2/3 resolve the modal rather than going to _pending_input as a user message.
    • cli.py:11321 also binds number keys while the slash-confirm modal is active, so pressing 1, 2, or 3 submits the corresponding choice immediately.
    • Regression coverage exists in tests/cli/test_slash_confirm_windows.py:103, including daemon-thread modal routing on linux and win32, and a no-raw-input deadlock guard.
    • The related subagent dangerous-command prompt deadlock mentioned in the discussion is covered by tools/delegate_tool.py:1544, which installs a non-interactive approval callback in child worker threads so subagent dangerous-command prompts do not fall back to input() and deadlock the parent TUI.

    Best implementation commit: 054f56857842a25b8ef5f627c7c951de28eee52a (fix: use TUI modal for slash confirmations). A later hardening commit, ab98818e5bf3d721d01f1b1899f60ceaeab2a2e9, keeps the modal path on native Windows. The slash-confirm fix is contained in release tag v2026.5.16.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High — major feature broken, no workaroundcomp/cliCLI entry point, hermes_cli/, setup wizardsweeper:implemented-on-mainSweeper: behavior already present on current maintype/bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions