fix(kanban): inject HERMES_HOME into worker subprocess env

Default spawn did not propagate HERMES_HOME when forking kanban workers.
The worker's env is copied from the parent via dict(os.environ), so
HERMES_HOME is absent. When the child then starts hermes -p <profile>,
the CLI's _apply_profile_override() runs before hermes_constants is
imported and get_hermes_home() falls back to ~/.hermes (the default
profile root), silently ignoring the profile's config.yaml.  Profile-
scoped fallback_providers, toolsets, and agent settings are therefore
never applied to kanban workers.

The fix injects HERMES_HOME into the worker's env using
resolve_profile_env(profile_arg) so the child reads the correct profile
directory instead of the default root.
This commit is contained in:
TurgutKural 2026-05-10 21:28:22 +03:00 committed by kshitij
parent 641e40c4bd
commit 5af315c4cc

View file

@ -3930,6 +3930,18 @@ def _default_spawn(
prompt = f"work kanban task {task.id}"
env = dict(os.environ)
# Inject HERMES_HOME so the worker reads the profile-scoped config.yaml
# (fallback_providers, toolsets, agent settings, etc.) instead of the root
# config. Without this, `env = dict(os.environ)` copies only the parent's
# env, and when the child process starts `hermes -p <name>` the
# _apply_profile_override() runs *before* hermes_constants is imported.
# If HERMES_HOME is absent from the child's env, get_hermes_home() falls
# back to Path.home() / ".hermes" (the DEFAULT profile root), ignoring the
# profile-specific config entirely. Fixes profile-scoped fallback_providers
# being invisible to kanban workers.
from hermes_cli.profiles import resolve_profile_env
env["HERMES_HOME"] = resolve_profile_env(profile_arg)
if task.tenant:
env["HERMES_TENANT"] = task.tenant
env["HERMES_KANBAN_TASK"] = task.id