hermes - ✅(Solved) Fix fix: only set HERMES_INTERACTIVE when stdin/stdout are real terminals [1 pull requests, 3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

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#17575Fetched 2026-04-30 06:46:38
View on GitHub
Comments
3
Participants
2
Timeline
9
Reactions
0
Timeline (top)
labeled ×4commented ×3cross-referenced ×1referenced ×1

Fix Action

Fixed

PR fix notes

PR #16529: fix: only set HERMES_INTERACTIVE when stdin/stdout are real terminals

Description (problem / solution / changelog)

What does this PR do?

In containerized/automated contexts (Docker, Paperclip integrations, cron), Hermes Agent is invoked via hermes chat -q with piped stdin/stdout. The CLI unconditionally set HERMES_INTERACTIVE=1, which triggers sudo password prompts and approval prompts even when no user is present. Each prompt waits 45s before timing out, causing slow/failing automated runs. This PR gates HERMES_INTERACTIVE=1 behind sys.stdin.isatty() && sys.stdout.isatty(), and adds PermissionError handling for ~/.hermes/.env reads in non-root container setups.

Related Issue

Fixes #17575

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)

Changes Made

  • cli.pymain():
    • HERMES_INTERACTIVE=1 is now only set when both sys.stdin.isatty() and sys.stdout.isatty() return True
    • Piped/automated callers (e.g., hermes chat -q, Paperclip heartbeats, cron) no longer trigger interactive prompts
  • hermes_cli/env_loader.pyload_hermes_dotenv():
    • Wrapped user_env.exists() in try/except PermissionError to prevent crashes when ~/.hermes/.env is unreadable (common in non-root container setups)
  • tests/hermes_cli/test_env_loader.py — added test_env_loader_permission_error_is_graceful
  • tests/hermes_cli/test_interactive_detection.py — new: 7 test cases covering isatty truth table

How to Test

  1. echo 'hello' | hermes chat -q — no approval/sudo prompts, runs to completion
  2. hermes (interactive TTY) — prompts still work, HERMES_INTERACTIVE=1 is set
  3. Run as non-root user with ~/.hermes/ having permissions 000 — no PermissionError crash
  4. Run via Paperclip adapter heartbeat — no 45s timeout stalls

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: Debian 13 (Docker)

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

N/A — this is a bug fix, not a new skill.

Screenshots / Logs

N/A — no UI changes

Changed files

  • cli.py (modified, +7/-3)
  • hermes_cli/env_loader.py (modified, +6/-2)
  • tests/hermes_cli/test_env_loader.py (modified, +18/-0)
  • tests/hermes_cli/test_interactive_detection.py (added, +67/-0)
RAW_BUFFERClick to expand / collapse

Problem

In containerized environments (Docker, Paperclip integrations, cron), Hermes Agent is invoked via hermes chat -q with piped stdin/stdout. The cli_main() function unconditionally sets HERMES_INTERACTIVE=1, triggering sudo password prompts and approval prompts even when no user is present. Each prompt waits 45s before timing out.

Expected Behavior

HERMES_INTERACTIVE should only be set when both stdin and stdout are real TTYs. Piped callers should never see interactive prompts.

Steps to Reproduce

  1. echo 'hello' | hermes chat -q — eventually times out after 45s
  2. Run via Paperclip adapter heartbeat — hangs on approval prompt

Proposed Fix

Gate HERMES_INTERACTIVE=1 behind sys.stdin.isatty() && sys.stdout.isatty(). Also handle PermissionError when ~/.hermes/.env is unreadable in non-root container setups.

PR: #16529

extent analysis

TL;DR

Set HERMES_INTERACTIVE based on the presence of a TTY for both stdin and stdout to prevent unnecessary prompts in non-interactive environments.

Guidance

  • Check the cli_main() function to ensure it correctly sets HERMES_INTERACTIVE only when both sys.stdin.isatty() and sys.stdout.isatty() return True.
  • Verify that the proposed fix handles PermissionError when ~/.hermes/.env is unreadable in non-root container setups.
  • Test the fix using the provided steps to reproduce, such as echo 'hello' | hermes chat -q, to ensure it no longer times out.
  • Consider reviewing PR #16529 for the specific implementation details of the proposed fix.

Example

import sys

def cli_main():
    if sys.stdin.isatty() and sys.stdout.isatty():
        os.environ['HERMES_INTERACTIVE'] = '1'
    # ... rest of the function ...

Notes

The fix assumes that the presence of a TTY for both stdin and stdout is a reliable indicator of an interactive environment. This may not be the case in all scenarios, and additional checks may be necessary.

Recommendation

Apply the proposed fix from PR #16529, as it addresses the root cause of the issue and provides a clear solution to the problem.

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 fix: only set HERMES_INTERACTIVE when stdin/stdout are real terminals [1 pull requests, 3 comments, 2 participants]