fix(approval): ignore leaked HERMES_CRON_SESSION in interactive sessions (#56771) - #56788
Closed
nankingjing wants to merge 1 commit into
Closed
nankingjing wants to merge 1 commit into
nankingjing wants to merge 1 commit into
Conversation
…ons (NousResearch#56771) The cron scheduler sets HERMES_CRON_SESSION process-wide; when that env leaks into a live gateway or CLI session, execute_code was incorrectly treated as a cron job and blocked under approvals.cron_mode: deny. Introduce _is_cron_approval_context() so explicit gateway/interactive markers and a bound session key override the leaked env while real cron jobs (including delivery-metadata platform bindings) still honor cron_mode. Fixes NousResearch#56771
Contributor
Competing fix for #56771 alongside #56784 (both edit |
2 tasks
Contributor
Author
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
_is_cron_approval_context()soHERMES_CRON_SESSIONalone does not classify a call as cron when a live interactive session is active.HERMES_GATEWAY_SESSION, interactive CLI flag, or a boundHERMES_SESSION_KEYcontextvar.platformbindings without a session key) still honorapprovals.cron_mode.Fixes #56771
Why
The cron scheduler sets
HERMES_CRON_SESSIONprocess-wide. When that env leaks into a Telegram/gateway session,execute_codewas blocked with the cron-deny message even though a user was present to approve.Test plan
pytest tests/tools/test_cron_session_env_leak_56771.py(3/3)pytest tests/tools/test_cron_approval_mode.py tests/tools/test_execute_code_approval_cluster.py(48/48)