The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(cron): preserve cleanup profile scope
Jony45aebc11b058
diff --git a/cron/scheduler.py b/cron/scheduler.pyindex 3fa97ff1561..d91f9ef374e 100644--- a/cron/scheduler.py+++ b/cron/scheduler.py@@ -45,6 +45,7 @@ from hermes_time import now as _hermes_nowfrom agent.interrupt_compat import request_hard_interruptfrom agent.delegation_context import (enter_non_dispatcher_owned_context, exit_non_dispatcher_owned_context)+from agent.memory_provider import ctx_boundlogger = logging.getLogger(__name__)@@ -1182,7 +1183,7 @@ def _run_cron_cleanup_with_timeout(# Daemon thread is deliberate: unlike ThreadPoolExecutor workers it is not joined at interpreter# exit if cleanup never returns, so the gateway can still shut down.worker = threading.Thread(- target=_runner, name=f"cron-cleanup-{job_id}", daemon=True)+ target=ctx_bound(_runner), name=f"cron-cleanup-{job_id}", daemon=True)worker.start()if not done.wait(timeout):logger.error(diff --git a/tests/cron/test_scheduler.py b/tests/cron/test_scheduler.pyindex ce7c554fadb..483209d6770 100644--- a/tests/cron/test_scheduler.py+++ b/tests/cron/test_scheduler.py@@ -1,6 +1,7 @@"""Tests for cron/scheduler.py — origin resolution, delivery routing, and error logging."""import contextlib+import contextvarsimport itertoolsimport jsonimport logging@@ -14,6 +15,7 @@ from cron.scheduler import (_build_job_prompt,_deliver_result,_merge_mcp_into_per_job_toolsets,+ _run_cron_cleanup_with_timeout,_resolve_cron_enabled_toolsets,_resolve_delivery_target,_summarize_cron_failure_for_delivery,@@ -24,6 +26,21 @@ from tools.env_passthrough import clear_env_passthroughfrom tools.credential_files import clear_credential_files+def test_cron_cleanup_worker_inherits_caller_contextvars():+ """Profile-scoped secrets must remain visible during threaded cleanup."""+ profile_scope = contextvars.ContextVar("test_cron_cleanup_profile_scope")+ profile_scope.set("profile-key")+ observed = []++ assert _run_cron_cleanup_with_timeout(+ lambda: observed.append(profile_scope.get(None)),+ job_id="context-scope",+ label="test cleanup",+ timeout_seconds=1,+ )+ assert observed == ["profile-key"]++class TestSummarizeCronFailureForDelivery:def test_embedded_429_in_source_identifier_is_not_a_rate_limit(self):summary = _summarize_cron_failure_for_delivery(