Skip to content

The agent that grows with you

docs(cron): explain why the secret-scope reset must stay function-level

ghosty93b8c18b8cb779
diff --git a/cron/scheduler.py b/cron/scheduler.py
index 575d60b26c6..dd385db12e5 100644
--- a/cron/scheduler.py
+++ b/cron/scheduler.py
@@ -7618,6 +7618,10 @@ def _run_one_job_body(
raise
return False
finally:
+ # Function-level on purpose: this must scope delivery, deferred-agent
+ # teardown, claim-loss handling and bookkeeping, not just run_job.
+ # An earlier revision reset inside the run block's finally, which left
+ # _deliver_result unscoped — do not move it back in a tidy-up.
if _scope_token is not None:
reset_secret_scope(_scope_token)