Skip to content

fix(cli): prevent update crash in non-TTY environments (Telegram)#2850

Closed
devorun wants to merge 2 commits into
NousResearch:mainfrom
devorun:patch-9
Closed

fix(cli): prevent update crash in non-TTY environments (Telegram)#2850
devorun wants to merge 2 commits into
NousResearch:mainfrom
devorun:patch-9

Conversation

@devorun

@devorun devorun commented Mar 24, 2026

Copy link
Copy Markdown
Contributor

Description
This PR fixes issue #2848 where triggering /update from a non-interactive context (like Telegram or systemd) causes the CLI to crash or exit with code 1.

Root Cause:
During an update that introduces new config options, cmd_update unconditionally prompts the user using input(). In headless environments without an attached TTY, this immediately throws an EOFError (or receives EOF), preventing the gateway from restarting and completing the update.

Fix:
Wrapped the input() call with a sys.stdin.isatty() guard. If it's a non-interactive session, it automatically skips the migration prompt by defaulting the response to "n", allowing the update and restart sequence to finish gracefully without duplicating log messages.

Closes #2848

What does this PR do?

Related Issue

Fixes #

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

How to Test

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes (required for bug fixes, strongly encouraged for features)
  • I've tested on my platform:

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS) per the compatibility guide — or N/A
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

For New Skills

  • This skill is broadly useful to most users (if bundled) — see Contributing Guide
  • SKILL.md follows the standard format (frontmatter, trigger conditions, steps, pitfalls)
  • No external dependencies that aren't already available (prefer stdlib, curl, existing Hermes tools)
  • I've tested the skill end-to-end: hermes --toolsets skills -q "Use the X skill to do Y"

Screenshots / Logs

devorun added 2 commits March 24, 2026 21:56
Description
This PR fixes issue NousResearch#2848 where triggering `/update` from a non-interactive context (like Telegram or systemd) causes the CLI to crash or exit with code 1.

Root Cause:
During an update that introduces new config options, `cmd_update` unconditionally prompts the user using `input()`. In headless environments without an attached TTY, this immediately throws an `EOFError` (or receives EOF), preventing the gateway from restarting and completing the update.

Fix:
Wrapped the `input()` call with a `sys.stdin.isatty()` guard. If it's a non-interactive session, it automatically skips the migration prompt by defaulting the response to `"n"`, allowing the update and restart sequence to finish gracefully without duplicating log messages.

Closes NousResearch#2848
Description
This PR fixes issue NousResearch#2848 where triggering `/update` from a non-interactive context (like Telegram or systemd) causes the CLI to crash or exit with code 1.

Root Cause:
During an update that introduces new config options, `cmd_update` unconditionally prompts the user using `input()`. In headless environments without an attached TTY, this immediately throws an `EOFError` (or receives EOF), preventing the gateway from restarting and completing the update.

Fix:
Wrapped the `input()` call with a `sys.stdin.isatty()` guard. If it's a non-interactive session, it automatically skips the migration prompt by defaulting the response to `"n"`, allowing the update and restart sequence to finish gracefully without duplicating log messages.

Closes NousResearch#2848
teknium1 added a commit that referenced this pull request Mar 26, 2026
cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR #2850 by devorun. Closes #2848.
@teknium1

Copy link
Copy Markdown
Contributor

Merged via salvage PR. Thanks @devorun!

teknium1 added a commit that referenced this pull request Mar 26, 2026
cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR #2850 by devorun. Closes #2848.
@teknium1 teknium1 closed this Mar 26, 2026
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
…3094)

cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR NousResearch#2850 by devorun. Closes NousResearch#2848.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
…3094)

cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR NousResearch#2850 by devorun. Closes NousResearch#2848.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
…3094)

cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR NousResearch#2850 by devorun. Closes NousResearch#2848.
olympus-terminal pushed a commit to olympus-terminal/hermes-agent that referenced this pull request May 16, 2026
…3094)

cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR NousResearch#2850 by devorun. Closes NousResearch#2848.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
…3094)

cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR NousResearch#2850 by devorun. Closes NousResearch#2848.
Egavasyug pushed a commit to Egavasyug/hermes-agent that referenced this pull request Jun 10, 2026
…3094)

cmd_update calls input() unconditionally during config migration.
In headless environments (Telegram gateway, systemd), there's no TTY,
so input() throws EOFError and the update crashes.

Guard with sys.stdin.isatty(), default to skipping the migration
prompt when non-interactive.

Salvaged from PR NousResearch#2850 by devorun. Closes NousResearch#2848.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

/update from Telegram fails when config migration needs interactive input

2 participants