Skip to content

fix(cli): guard interactive chat without tty - #22361

Open
yyydao wants to merge 1 commit into
NousResearch:mainfrom
yyydao:fix/headless-chat-tty-guard
Open

fix(cli): guard interactive chat without tty#22361
yyydao wants to merge 1 commit into
NousResearch:mainfrom
yyydao:fix/headless-chat-tty-guard

Conversation

@yyydao

@yyydao yyydao commented May 9, 2026

Copy link
Copy Markdown

Summary
- Add an early TTY guard for interactive hermes chat / bare hermes
- Avoid prompt_toolkit crashing on macOS when stdin is a pipe or regular file
- Keep hermes chat -q ... and image single-query flows usable in non-interactive environments

Test Plan
- venv/bin/python -m pytest tests/hermes_cli/test_setup_noninteractive.py -q -o 'addopts='
- venv/bin/python -m pytest tests/hermes_cli/test_tui_resume_flow.py tests/hermes_cli/test_setup_noninteractive.py -q -o 'addopts='
- printf '' | ./venv/bin/hermes chat --ignore-rules --ignore-user-config

@alt-glitch alt-glitch added type/bug Something isn't working P2 Medium — degraded but workaround exists comp/cli CLI entry point, hermes_cli/, setup wizard labels May 9, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

Duplicate of #18136 (and #19092, #8842, #7865). Same TTY guard for interactive chat without tty. Multiple competing PRs exist.

@teknium1 teknium1 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the focused guard and regression coverage.

Suggested changes

  • Please add a no-TTY --image regression case next to the new -q case. Current cli.py:16043 makes either query or image select the one-shot path, and the proposed guard intentionally exempts both. Covering the image branch will preserve the behavior stated in this PR.

The premise remains valid on current main: hermes_cli/main.py:2404 invokes the classic CLI after the no-provider check, and cli.py:16265 enters its interactive prompt_toolkit loop whenever neither query nor image is supplied. This is an automated hermes-sweeper review.

assert "hermes chat" in err
assert "requires an interactive terminal" in err

def test_chat_headless_single_query_still_allowed(self):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add the equivalent no-TTY image=... case here. cli.py:16043 treats an image without -q as one-shot mode too, and the production guard explicitly exempts it.

@teknium1 teknium1 added sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard P2 Medium — degraded but workaround exists sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants