mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-07-25 17:18:11 +00:00
The cron scheduler was mutating process-global state in two places: 1. no_agent path called os.chdir() which changed the global process cwd, leaking into concurrent gateway sessions. 2. The agent path set os.environ['TERMINAL_CWD'] which any gateway session could read during context-file discovery via resolve_context_cwd/build_context_files_prompt. Fix: - no_agent path: pass workdir as subprocess cwd parameter to _run_job_script() instead of os.chdir(). The Python process cwd is never mutated. - Agent path: in addition to the lock-serialized TERMINAL_CWD, also set the per-context _SESSION_CWD ContextVar from agent.runtime_cwd. This ContextVar is scoped to the current thread/context and NEVER leaks into other sessions. resolve_context_cwd() checks _SESSION_CWD first, so the cron's own context file discovery uses the correct workdir, while gateway sessions (which have no override) fall through to their own TERMINAL_CWD. |
||
|---|---|---|
| .. | ||
| scripts | ||
| __init__.py | ||
| blueprint_catalog.py | ||
| executions.py | ||
| jobs.py | ||
| lifecycle_guard.py | ||
| scheduler.py | ||
| scheduler_provider.py | ||
| suggestion_catalog.py | ||
| suggestions.py | ||