fix: guard print() calls in run_conversation() against OSError#858
Closed
teyrebaz33 wants to merge 1 commit intoNousResearch:mainfrom
Closed
fix: guard print() calls in run_conversation() against OSError#858teyrebaz33 wants to merge 1 commit intoNousResearch:mainfrom
teyrebaz33 wants to merge 1 commit intoNousResearch:mainfrom
Conversation
When hermes-agent runs as a systemd service or headless daemon, the stdout pipe can become unavailable (idle timeout, buffer exhaustion, socket reset), causing print() to raise OSError [Errno 5] Input/output error. Wrap 7 affected print() calls in try/except OSError: - Cosmetic lines (quiet_mode display, interrupt/retry status, context length discovery): silently swallowed with pass - Error handler lines: fall back to logger.error/warning so the message is not lost Closes NousResearch#845
Contributor
Author
|
The failing check ( |
Contributor
|
Closing — the approach of wrapping individual print() calls doesn't scale. There are 68 print() calls in run_conversation() alone, and this PR guards only 7 of them (leaving adjacent prints in the same blocks unguarded). We're implementing a systematic fix that covers all of them without touching each call site. Thanks for bringing this to our attention — the issue is real and the root cause analysis in #845 was excellent. |
This was referenced Mar 11, 2026
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.
Closes #845
Problem
When hermes-agent runs as a systemd service or headless daemon, the stdout pipe can become unavailable (idle timeout, buffer exhaustion, socket reset), causing
print()to raiseOSError: [Errno 5] Input/output error. This crashesrun_conversation()and causes cron jobs to be marked as failed.Changes
Wrap 7 affected
print()calls intry/except OSErrorinrun_agent.py:passpasslogger.warninglogger.warninglogger.errorpasslogger.errorCosmetic lines are silently dropped. Error handler lines fall back to
loggerso the message is preserved.Testing
3 new tests in
TestPrintOSErrorGuard. Full suite: 2863 passed.