hermes - ✅(Solved) Fix [Bug]: RuntimeWarning “run_in_terminal... was never awaited” when confirming /clear or /new in CLI [2 pull requests, 3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#23297Fetched 2026-05-11 03:30:05
View on GitHub
Comments
3
Participants
3
Timeline
10
Reactions
0
Timeline (top)
commented ×3labeled ×3cross-referenced ×2referenced ×2

Error Message

/home/username/.hermes/hermes-agent/cli.py:12438: RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited

logger.warning("process_loop unhandled error (msg may be lost): %s", e) RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Root Cause

Root Cause Analysis (optional)

Fix Action

Temporary Workaround

From CLI...

hermes config set approvals.destructive_slash_confirm false

PR fix notes

PR #23301: fix(cli): guard _prompt_text_input against background-thread call to prevent RuntimeWarning

Description (problem / solution / changelog)

Summary

_prompt_text_input calls run_in_terminal() which requires an asyncio event loop. When called from the process_loop daemon thread (e.g. during _confirm_destructive_slash for /clear or /new), the coroutine returned by run_in_terminal is never awaited, producing:

RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited

Root Cause

_prompt_text_input checks if self._app: and calls run_in_terminal(_ask), but does not verify whether it's running on the main prompt_toolkit thread. The process_loop background thread has self._app set (it's a shared attribute), so the run_in_terminal path is taken even when no event loop is available.

The sibling method _curses_single_select already handles this correctly with a threading.current_thread() is threading.main_thread() guard.

Fix

Add the same in_main_thread guard to _prompt_text_input: when running on a background thread, fall back to direct input() instead of run_in_terminal().

Regression Coverage

  • test_prompt_text_input_skips_run_in_terminal_from_background_thread — verifies run_in_terminal is NOT called from a background thread
  • test_prompt_text_input_uses_run_in_terminal_from_main_thread — verifies the normal prompt_toolkit path is still used from the main thread
  • All 657 existing CLI tests pass (pre-existing ruamel import failure in test_cli_save_config_value.py is unrelated)

Testing

scripts/run_tests.sh tests/cli/test_prompt_text_input_thread_guard.py tests/cli/test_destructive_slash_confirm.py tests/hermes_cli/test_destructive_slash_confirm_gate.py

Fixes [Bug]: RuntimeWarning "run_in_terminal... was never awaited" when confirming /clear or /new in CLI #23297

Changed files

  • cli.py (modified, +7/-1)
  • tests/cli/test_prompt_text_input_thread_guard.py (added, +86/-0)

PR #23317: fix(cli): suppress RuntimeWarning from unawaited run_in_terminal in prompt_toolkit 3.0.52+

Description (problem / solution / changelog)

Summary

  • Fixes RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited that appears when confirming /clear, /new, /reset, or /undo in the interactive CLI
  • prompt_toolkit 3.0.52+ changed run_in_terminal() to return an Awaitable. Four call sites in cli.py invoke it fire-and-forget because the callback is scheduled on the already-running event loop and executes correctly
  • Suppresses the warning at each call site with warnings.catch_warnings() since the callback semantics are unchanged

Affected call sites

FunctionTrigger
_prompt_text_input/clear, /new confirmation prompts
_run_curses_pickercurses-based pickers
handle_ctrl_z (key binding)Ctrl+Z suspend
_cprint._schedulebackground thread print

Fixes #23297.

Changed files

  • cli.py (modified, +27/-4)
  • gateway/run.py (modified, +6/-9)

Code Example

RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited
    and logs:
    cli.py:12438 logger.warning("process_loop unhandled error (msg may be lost): %s", e)

---

Report       https://paste.rs/wO2TT
agent.log    https://paste.rs/7zuVL
gateway.log  https://paste.rs/cB3qY

---

/home/username/.hermes/hermes-agent/cli.py:12438: RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited

logger.warning("process_loop unhandled error (msg may be lost): %s", e)
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback
RAW_BUFFERClick to expand / collapse

Bug Description

After recent destructive slash confirmation UX changes, using /clear or /new in the interactive CLI shows the expected confirmation prompt, but then emits:
    RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited
    and logs:
    cli.py:12438 logger.warning("process_loop unhandled error (msg may be lost): %s", e)
The confirmation prompt appears intentional; the RuntimeWarning appears to be a regression in the CLI input path.

Steps to Reproduce

  1. Start interactive CLI: hermes
  2. Ensure confirmations are enabled: approvals.destructive_slash_confirm: true
  3. Run /clear (or /new)
  4. Confirmation prompt appears with choices [1]/[2]/[3]
  5. Choose 1 (Approve Once) or 2 (Always Approve)
  6. Observe RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited

Expected Behavior

/clear and /new should complete (or cancel) without coroutine warnings or unhandled-error logs.

Actual Behavior

Prompt is shown, but CLI emits RuntimeWarning about unawaited coroutine via run_in_terminal path.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

N/A (CLI only)

Debug Report

Report       https://paste.rs/wO2TT
agent.log    https://paste.rs/7zuVL
gateway.log  https://paste.rs/cB3qY

Operating System

Ubuntu 26.0.4

Python Version

3.11.15

Hermes Version

Hermes Agent v0.13.0 (2026.5.7)

Additional Logs / Traceback (optional)

/home/username/.hermes/hermes-agent/cli.py:12438: RuntimeWarning: coroutine 'run_in_terminal.<locals>.run' was never awaited

logger.warning("process_loop unhandled error (msg may be lost): %s", e)
    RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Root Cause Analysis (optional)

Likely mismatch with prompt_toolkit API contract in current dependency:

  • prompt_toolkit 3.0.52 run_in_terminal(...) -> Awaitable[_T]
  • cli.py _prompt_text_input currently calls run_in_terminal(_ask) without await.
  • /clear and /new now route through _confirm_destructive_slash (commit b9c001116...), which calls _prompt_text_input, making this path frequent.

Relevant code/commits:

  • b9c001116e2bc6e2b112d9338ab6ce10040896a0 feat: confirm prompt for destructive slash commands (#4069) (#22687) Added _confirm_destructive_slash and wired /clear,/new,/undo
  • 06f862fa1b... feat(cli): add native /model picker modal for provider → model selection Introduced _prompt_text_input with run_in_terminal(_ask) unawaited usage

Proposed Fix (optional)

Update CLI call sites to handle run_in_terminal as awaitable in prompt_toolkit>=3.0.52 (especially _prompt_text_input and _run_curses_picker, plus other run_in_terminal call sites).

Temporary Workaround

From CLI...

hermes config set approvals.destructive_slash_confirm false

Are you willing to submit a PR for this?

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

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - ✅(Solved) Fix [Bug]: RuntimeWarning “run_in_terminal... was never awaited” when confirming /clear or /new in CLI [2 pull requests, 3 comments, 3 participants]