fix(cron): clean up HERMES_CRON_SESSION env var after each job run (#59236) - #59242
Closed
webtecnica wants to merge 1 commit into
Closed
fix(cron): clean up HERMES_CRON_SESSION env var after each job run (#59236)#59242webtecnica wants to merge 1 commit into
webtecnica wants to merge 1 commit into
Conversation
Collaborator
Duplicate of #57124 — both PRs add the byte-identical |
The in-process cron scheduler sets `os.environ["HERMES_CRON_SESSION"] = "1"`
process-wide but never clears it. Since `InProcessCronScheduler` runs in the
same process as the gateway, this env var leaks into every interactive session
after the first cron tick fires, causing the approval system to incorrectly
apply cron_mode (e.g. blocking execute_code with "cron jobs run without a
user present") to interactive gateway sessions.
Fix: add `os.environ.pop("HERMES_CRON_SESSION", None)` to the run_job()
finally block, alongside the existing TERMINAL_CWD cleanup and ContextVar
clear. The marker is now only present while a cron job is actively running.
Closes NousResearch#59236
webtecnica
force-pushed
the
fix/59236-cron-session-cleanup
branch
from
July 6, 2026 05:16
899bc99 to
a4c3da6
Compare
Contributor
Author
|
Closing as duplicate of #57124 (opened 2026-07-02, byte-identical fix in the same |
Contributor
Author
|
Already commented — closing as duplicate. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #59179 review feedback: the in-process cron scheduler sets
os.environ["HERMES_CRON_SESSION"] = "1"process-wide but never clears it, causing the cron-mode approval behavior to leak into interactive gateway sessions.Problem
When
InProcessCronSchedulerfires a job inside the gateway process,HERMES_CRON_SESSION=1persists inos.environfor the lifetime of the process. Every subsequent interactive session (Telegram, Discord, etc.) inherits this marker, so:cron_mode: deny(default):execute_codeand dangerous commands are hard-blocked with "cron jobs run without a user present"cron_mode: approve: dangerous commands are auto-approved without user promptFix
1 line added in
cron/scheduler.py:run_job()finally block (line 3187):Placed alongside the existing
TERMINAL_CWDcleanup and ContextVar clear — the marker is now only present while a cron job is actively running.Why this approach
The scheduler already has a well-established finally block for exactly this kind of cleanup (TERMINAL_CWD restore, ContextVar clear, lock release). Adding the
pophere is:Closes #59236