Skip to content

fix: batch of 5 small contributor fixes — PortAudio, SafeWriter, IMAP, thread lock, prefill - #2466

Merged
teknium1 merged 5 commits into
mainfrom
hermes/hermes-40b195db
Mar 22, 2026
Merged

fix: batch of 5 small contributor fixes — PortAudio, SafeWriter, IMAP, thread lock, prefill#2466
teknium1 merged 5 commits into
mainfrom
hermes/hermes-40b195db

Conversation

@teknium1

Copy link
Copy Markdown
Contributor

Batch salvage of 5 small, clean fixes from open PRs:

#2440 (@itenev) — Better error message when PortAudio is missing: shows apt install libportaudio2 / brew install portaudio instead of generic error.

#2431 (@Bartok9) — Catch ValueError in _SafeWriter alongside OSError. Subagent thread teardown can close stdout between writes, raising "I/O operation on closed file" instead of broken pipe.

#2289 (@Mibayy) — Guard IMAP search results: data and data[0] instead of just data[0]. Prevents IndexError when IMAP returns empty list.

#2288 (@Mibayy) — Add self._lock around session_count() and message_count() in SessionDB. Other methods already use the lock; these two didn't.

#2129 (@ygd58) — Strip trailing empty assistant messages before API calls. Responses API reasoning-only turns leave empty assistant messages that cause prefill rejection on Chat Completions / Anthropic.

All authorship preserved.

Ivelin Tenev and others added 5 commits March 22, 2026 04:38
When sounddevice is installed but libportaudio2 is not present on the
system, the OSError was caught together with ImportError and showed a
generic 'pip install sounddevice' message that sent users down the wrong
path.

Split the except clause to give a clear, actionable message for the
OSError case, including the correct apt/brew commands to install the
system library.
When subagents run in ThreadPoolExecutor threads, the shared stdout handle
can close between thread teardown and KawaiiSpinner cleanup. Python raises
ValueError (not OSError) for I/O operations on closed files:
  ValueError: I/O operation on closed file

The _SafeWriter class was only catching OSError, missing this case.

Changes:
- Add ValueError to exception handling in write(), flush(), and isatty()
- Update docstring to document the ThreadPoolExecutor teardown scenario

Fixes #2428
imap.uid('search') can return data=[] when the mailbox is empty or
has no matching messages. Accessing data[0] without checking len first
raises IndexError: list index out of range.

Fixed at both call sites in gateway/platforms/email.py:
- Line 233 (connect): ALL search on startup
- Line 298 (fetch): UNSEEN search in the polling loop

Closes #2137
…unt()

Both methods accessed self._conn without self._lock, breaking the
thread-safety contract documented on SessionDB (line 111). All 22 other
DB methods use with self._lock — these two were the only exceptions.

In the gateway's multi-threaded environment (multiple platform reader
threads + single writer) this could cause cursor interleaving,
sqlite3.ProgrammingError, or inconsistent COUNT results.

Closes #2130
@teknium1
teknium1 merged commit edda0e3 into main Mar 22, 2026
1 check failed
teknium1 added a commit that referenced this pull request Mar 22, 2026
Reverts the sanitizer addition from PR #2466 (originally #2129).
We already have _empty_content_retries handling for reasoning-only
responses. The trailing strip risks silently eating valid messages
and is redundant with existing empty-content handling.
outsourc-e pushed a commit to outsourc-e/hermes-agent that referenced this pull request Mar 26, 2026
Reverts the sanitizer addition from PR NousResearch#2466 (originally NousResearch#2129).
We already have _empty_content_retries handling for reasoning-only
responses. The trailing strip risks silently eating valid messages
and is redundant with existing empty-content handling.
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
fix: batch of 5 small contributor fixes — PortAudio, SafeWriter, IMAP, thread lock, prefill
angelburgosrosado pushed a commit to angelburgosrosado/hermes-agent that referenced this pull request Apr 27, 2026
Reverts the sanitizer addition from PR NousResearch#2466 (originally NousResearch#2129).
We already have _empty_content_retries handling for reasoning-only
responses. The trailing strip risks silently eating valid messages
and is redundant with existing empty-content handling.
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
fix: batch of 5 small contributor fixes — PortAudio, SafeWriter, IMAP, thread lock, prefill
02356abc pushed a commit to 02356abc/hermes-agent that referenced this pull request May 14, 2026
Reverts the sanitizer addition from PR NousResearch#2466 (originally NousResearch#2129).
We already have _empty_content_retries handling for reasoning-only
responses. The trailing strip risks silently eating valid messages
and is redundant with existing empty-content handling.
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
fix: batch of 5 small contributor fixes — PortAudio, SafeWriter, IMAP, thread lock, prefill
gweeteve pushed a commit to gweeteve/hermes-agent that referenced this pull request Jun 2, 2026
Reverts the sanitizer addition from PR NousResearch#2466 (originally NousResearch#2129).
We already have _empty_content_retries handling for reasoning-only
responses. The trailing strip risks silently eating valid messages
and is redundant with existing empty-content handling.
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
fix: batch of 5 small contributor fixes — PortAudio, SafeWriter, IMAP, thread lock, prefill
waefrebeorn pushed a commit to waefrebeorn/slermes that referenced this pull request Jul 2, 2026
Reverts the sanitizer addition from PR NousResearch#2466 (originally NousResearch#2129).
We already have _empty_content_retries handling for reasoning-only
responses. The trailing strip risks silently eating valid messages
and is redundant with existing empty-content handling.
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.

2 participants