Skip to content

fix(cron): isolate cron approval context - #69566

Closed
seungjins wants to merge 1 commit into
NousResearch:mainfrom
seungjins:fix/cron-approval-context-leak-v2
Closed

fix(cron): isolate cron approval context#69566
seungjins wants to merge 1 commit into
NousResearch:mainfrom
seungjins:fix/cron-approval-context-leak-v2

Conversation

@seungjins

Copy link
Copy Markdown

Summary

  • keep cron execution identity in per-task ContextVars instead of process-global environment state
  • prevent stale cron flags from poisoning live gateway approval decisions
  • preserve cron fail-closed approval behavior while live gateway approvals remain interactive

This is a current-main re-derivation of the intent in #36004, whose original fork branch is no longer writable by the submitting account and has become conflicting.

Verification

  • pytest tests/gateway/test_session_env.py tests/tools/test_execute_code_approval_cluster.py tests/tools/test_cron_approval_mode.py tests/cron/test_cron_script.py tests/cron/test_scheduler.py -q
  • 333 passed (3 pre-existing runtime/deprecation warnings)

@alt-glitch alt-glitch added type/bug Something isn't working comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/gateway Gateway runner, session dispatch, delivery comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades duplicate This issue or pull request already exists labels Jul 22, 2026
@alt-glitch

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Duplicate of #58663: both implement the same ContextVar-based cron approval isolation. #58663 is the more complete current patch because it resets the ContextVar token in finally, preserving the standalone environment fallback.

(cherry picked from commit 27346c2ba8da202fb41f2fa8877a45563a1d7f45)
@seungjins
seungjins force-pushed the fix/cron-approval-context-leak-v2 branch from 22b4817 to 410a2ac Compare July 22, 2026 19:36
@seungjins

Copy link
Copy Markdown
Author

Closing as duplicate of #58663, which contains the same ContextVar isolation plus the stronger token-reset/fallback coverage and has a green required-check suite.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint comp/cron Cron scheduler and job management comp/gateway Gateway runner, session dispatch, delivery duplicate This issue or pull request already exists P2 Medium — degraded but workaround exists sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants