mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-09 13:21:42 +00:00
Session vars (HERMES_SESSION_*) have a process-global os.environ mirror written last-writer-wins as a CLI/cron fallback and never cleared. Under a concurrent multi-session host (messaging gateway, ACP adapter, API server, TUI) that global belongs to whichever turn wrote it last. A subprocess spawned from a task whose session ContextVar is _UNSET (a sibling task that never bound, or one that inherited another session's context) inherited the FOREIGN global and acted on another session's identity. Add a session_context_engaged() latch (set once any host calls set_session_vars) and route both terminal spawn paths through a single _inject_session_context_env chokepoint: once engaged, a bound ContextVar (incl. "") is authoritative and an _UNSET var is STRIPPED rather than inheriting the possibly-foreign global. Pure single-process CLI/one-shot (never engaged) keeps the inherited fallback. Salvaged from #50531 (supersedes #49922). local.py hunk re-applied by intent onto the current hermes_subprocess_env refactor. Co-authored-by: PolyphonyRequiem <3107779+PolyphonyRequiem@users.noreply.github.com> |
||
|---|---|---|
| .. | ||
| __init__.py | ||
| base.py | ||
| daytona.py | ||
| docker.py | ||
| file_sync.py | ||
| local.py | ||
| managed_modal.py | ||
| modal.py | ||
| modal_utils.py | ||
| singularity.py | ||
| ssh.py | ||