agentmemory icon indicating copy to clipboard operation
agentmemory copied to clipboard

Windows: _resolve_project hangs forever inside a Hermes Kanban worker (git child inherits the stdin control pipe)

Open cbsincool opened this issue 1 month ago • 1 comments

_resolve_project freezes every Hermes Kanban worker on Windows (git child inherits the stdin control pipe)

Summary

When this plugin is enabled, every Hermes Kanban card on Windows stays running forever. The worker process is alive but makes no model call, writes no message, and produces no log beyond one Session: <id> line. The plugin is what freezes it, during AgentMemoryProvider.initialize().

Disabling the plugin makes cards complete normally; re-enabling it brings the hang back.

Root cause

_resolve_project shells out to git with no stdin argument:

out = subprocess.run(
    ["git", "rev-parse", "--show-toplevel", "--git-dir", "--git-common-dir"],
    cwd=cwd,
    capture_output=True,
    text=True,
    timeout=5,
).stdout.strip()

A Hermes Kanban worker's stdin is not a console or /dev/null — it is the owner gateway's bootstrap/control pipe, and Hermes has a dedicated thread (WorkerControls.read → read_frame) synchronously blocked reading it. On Windows, while a synchronous ReadFile is pending on a non-overlapped pipe handle, other operations on that handle block. The git child inherits the handle, so:

  • timeout=5 kills only the git launcher, not the orphan,
  • communicate() then waits for EOF on pipes the orphaned child still holds,
  • the call never returns.

This is the same defect class as Hermes issue NousResearch/hermes-agent#146440 (version_info.py::_run_git), but this call site is inside a third-party plugin, so core cannot compensate for it — and it fires during agent construction, which means the worker never even reaches the point where it logs anything.

Observed stack

Captured from the live stalled python -m agent.managed_worker process with _remote_debugging.RemoteUnwinder(pid, all_threads=True):

thread 5256  Thread.join
             subprocess.py:1662 Popen._communicate
             subprocess.py:1221 Popen.communicate
             subprocess.py:566  subprocess.run
             __init__.py:36     _resolve_project
             __init__.py:284    AgentMemoryProvider.initialize
thread 17064 managed_worker.py:102 read_frame
             managed_worker.py:213 WorkerControls.read

Two Popen._readerthread threads were also parked in subprocess.py:1614.

Fix

         out = subprocess.run(
             ["git", "rev-parse", "--show-toplevel", "--git-dir", "--git-common-dir"],
             cwd=cwd,
             capture_output=True,
             text=True,
             timeout=5,
+            # A Kanban worker's stdin is the owner's control pipe with a synchronous read
+            # pending; an inheriting child blocks on Windows and communicate() never sees EOF.
+            stdin=subprocess.DEVNULL,
         ).stdout.strip()

Worth auditing the rest of this plugin for the same pattern — any subprocess that can run while a worker is bound has this hazard, not just _resolve_project.

Verification

With the fix, on Windows 11 + Hermes 0.22.5 + Python 3.14.9:

  • one Kanban card assigned to a profile with this plugin enabled: done in 20 s, real summary;
  • four cards released at once across four profiles: all four done within 60 s, each with a distinct, correct summary;
  • the card log went from 81 B (Session: only) to a real trace.

Before the fix, 100% of cards froze; no card had ever completed on this install under the managed-worker path.

Environment

  • Windows 11, Hermes Agent v0.22.5 (git install, bf0203a794a0), Python 3.14.9
  • single multiplexed gateway serving multiple profiles, Kanban dispatcher embedded
  • agentmemory plugin v0.9.31, installed per-profile under profiles/<name>/plugins/agentmemory/
  • server reachable at its configured URL (the hang is not a connectivity problem — it happens before any server call)

cbsincool avatar Nov 03 '26 01:11 cbsincool

Fixed on main by #1663: the Hermes project git probe runs with stdin set to DEVNULL, so it no longer inherits the worker's control pipe. Ships in 0.9.32.

rohitg00 avatar Nov 04 '26 09:11 rohitg00