fix: only set HERMES_INTERACTIVE when stdin/stdout are real terminals#16529
Open
cxgreat2014 wants to merge 2 commits into
Open
fix: only set HERMES_INTERACTIVE when stdin/stdout are real terminals#16529cxgreat2014 wants to merge 2 commits into
cxgreat2014 wants to merge 2 commits into
Conversation
- cli.py: HERMES_INTERACTIVE=1 was set unconditionally at cli_main() entry, causing sudo password prompts and approval prompts even in non-interactive mode (hermes chat -q, Paperclip heartbeats, cron). Now gated behind sys.stdin.isatty() && sys.stdout.isatty(). - env_loader.py: user_env.exists() could crash with PermissionError when the .hermes directory is owned by a different user (common in Docker/container setups where hermes runs as non-root). Now catches PermissionError and gracefully skips .env loading.
Author
|
Hi maintainers 👋 Just following up — tests pass (2014 passed, 6 unrelated env failures), and the PR body has been updated with the full template. Would appreciate a review when you have a moment. Thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
In containerized/automated contexts (Docker, Paperclip integrations, cron), Hermes Agent is invoked via
hermes chat -qwith piped stdin/stdout. The CLI unconditionally setHERMES_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 gatesHERMES_INTERACTIVE=1behindsys.stdin.isatty() && sys.stdout.isatty(), and adds PermissionError handling for~/.hermes/.envreads in non-root container setups.Related Issue
Fixes #17575
Type of Change
Changes Made
cli.py—main():HERMES_INTERACTIVE=1is now only set when bothsys.stdin.isatty()andsys.stdout.isatty()return Truehermes chat -q, Paperclip heartbeats, cron) no longer trigger interactive promptshermes_cli/env_loader.py—load_hermes_dotenv():user_env.exists()in try/except PermissionError to prevent crashes when~/.hermes/.envis unreadable (common in non-root container setups)tests/hermes_cli/test_env_loader.py— addedtest_env_loader_permission_error_is_gracefultests/hermes_cli/test_interactive_detection.py— new: 7 test cases covering isatty truth tableHow to Test
echo 'hello' | hermes chat -q— no approval/sudo prompts, runs to completionhermes(interactive TTY) — prompts still work, HERMES_INTERACTIVE=1 is set~/.hermes/having permissions 000 — no PermissionError crashChecklist
Code
fix(scope):,feat(scope):, etc.)pytest tests/ -qand all tests passDocumentation & Housekeeping
docs/, docstrings) — or N/Acli-config.yaml.exampleif I added/changed config keys — or N/ACONTRIBUTING.mdorAGENTS.mdif I changed architecture or workflows — or N/AFor New Skills
N/A — this is a bug fix, not a new skill.
Screenshots / Logs
N/A — no UI changes