Skip to content

kanban: fix worker spawn ModuleNotFoundError by setting PYTHONPATH - #144142

Open
u12contactme-collab wants to merge 1 commit into
NousResearch:mainfrom
u12contactme-collab:fix/kanban-dispatcher-worker-pythonpath
Open

u12contactme-collab wants to merge 1 commit into
NousResearch:mainfrom
u12contactme-collab:fix/kanban-dispatcher-worker-pythonpath

Conversation

@u12contactme-collab

Copy link
Copy Markdown

Summary

Fix

Set PYTHONPATH on the worker's environment (right where the rest of the worker env is already built in kanban_db_dispatch.py) to the same root the launcher inserts into sys.path. Deliberately does not change _module_hermes_argv's choice of sys.executable -m hermes_cli.main — that invocation is a documented, deliberate mitigation for a PATH-shadowing attack (#111569), so this adds the missing piece instead of changing it.

Test plan

  • Reproduced the crash locally on a Windows managed-runtime install (worker died within 61-82s on every attempt, every time).
  • Applied the fix, restarted the gateway, unblocked the same stuck task, ran a manual dispatch pass.
  • Confirmed the worker process stayed alive for minutes with real heartbeats and CPU time, well past the point every prior attempt had already crashed, and completed normally.

🤖 Generated with Claude Code

The hermes.cmd/hermes.exe launcher makes hermes_cli importable via an
in-process sys.path.insert(0, <hermes-agent root>) after explicitly
popping any inherited PYTHONPATH. That fixup only affects the current
process, never a child spawned later.

The kanban dispatcher spawns every worker as a bare
`sys.executable -m hermes_cli.main` (_module_hermes_argv), bypassing
the launcher shim entirely. The fresh child interpreter has no way to
import hermes_cli and crashes immediately with:
    ModuleNotFoundError: No module named 'hermes_cli'

This hits every kanban-dispatched worker on managed-runtime installs,
not just newly created profiles. Matches several independently filed
reports of the same symptom (NousResearch#125121, NousResearch#122620, NousResearch#122500, NousResearch#30943,
NousResearch#134503, NousResearch#122299, NousResearch#137079, NousResearch#135640, NousResearch#124542).

Fix: give the child the one thing that does survive a spawn (an env
var) pointing at the same root the launcher inserts into sys.path,
right where the worker's environment is otherwise built. Deliberately
leaves _module_hermes_argv's choice of sys.executable -m hermes_cli.main
untouched -- that is a documented, deliberate mitigation for a
PATH-shadowing attack (NousResearch#111569), so this adds the missing piece instead
of changing the invocation.

Verified live: previously the worker crashed within 61-82s on every
attempt. After this fix the same task ran for minutes with real
heartbeats and CPU time before completing normally.
@alt-glitch alt-glitch added comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management os/windows Native Windows behaviour or breakage: PowerShell install, Windows paths, cmd.exe, WSL-vs-native diff P2 Medium — degraded but workaround exists type/bug Something isn't working labels Oct 24, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cli CLI entry point, hermes_cli/, setup wizard comp/cron Cron scheduler and job management os/windows Native Windows behaviour or breakage: PowerShell install, Windows paths, cmd.exe, WSL-vs-native diff P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants