The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: preserve cron delivery silence and incident acknowledgements
Teknium0c7f676ee415
diff --git a/cron/scheduler.py b/cron/scheduler.pyindex 42c51c96d95..05105ccb887 100644--- a/cron/scheduler.py+++ b/cron/scheduler.py@@ -1090,15 +1090,16 @@ def drain_delivery_queue(adapters, loop) -> int:# open/create entirely until a worker has actually queued something.if not _path().exists():return 0- return drain(- lambda queued_job, queued_content, queued_for_failure: _deliver_result(- queued_job,- queued_content,- adapters=adapters,- loop=loop,+ def send(queued_job, queued_content, queued_for_failure):+ error = _deliver_result(+ queued_job, queued_content, adapters=adapters, loop=loop,for_failure=queued_for_failure,)- )+ if not error and queued_for_failure:+ _mark_incident_alerted(queued_job.get("_failure_incident_id"))+ return error++ return drain(send)_DEFAULT_SCRIPT_TIMEOUT = 3600 # seconds (1 hour)@@ -2694,7 +2695,12 @@ def _save_compose_deliver(execution_id = job.get('execution_id')if execution_id and not job.get('no_agent'):from cron.delivery_queue import enqueue- queued = enqueue(execution_id, job, deliver_content, for_failure=not d.success)+ if _normalize_deliver_value(_delivery_lane_value(job, for_failure=not d.success)) == "local":+ return+ queued_job = dict(job)+ if d.failure_incident_id:+ queued_job["_failure_incident_id"] = d.failure_incident_id+ queued = enqueue(execution_id, queued_job, deliver_content, for_failure=not d.success)job['last_delivery_queued'] = {'canonical': {'status': queued['status'], 'execution_id': execution_id}}returnd.unresolved_origin = (diff --git a/tests/cron/test_cron_incidents.py b/tests/cron/test_cron_incidents.pyindex aa5a405bcf4..039d372521f 100644--- a/tests/cron/test_cron_incidents.py+++ b/tests/cron/test_cron_incidents.py@@ -30,7 +30,7 @@ def _job(**overrides):"enabled": True,"state": "scheduled","schedule": {"kind": "interval", "minutes": 5, "display": "every 5m"},- "deliver": "local",+ "deliver": "slack:alerts","model": "test-model","provider": None,"provider_snapshot": "openrouter",@@ -45,6 +45,10 @@ def _tick_failing(job, tmp_path, deliveries, error="boom unrelated"):path that composes the per-run failure ping). Mirrors the preflight alert-onceharness so the incident gating is exercised through the real scheduler."""+ (tmp_path / "config.yaml").write_text(+ "platforms:\n slack:\n enabled: true\n token: xoxb-test\n"+ )+def fake_deliver(execution_id, jb, content, **kwargs):deliveries.append(content)return {"status": "pending"}diff --git a/tests/cron/test_cron_no_agent.py b/tests/cron/test_cron_no_agent.pyindex 743ef3ca2b5..fc166243f55 100644--- a/tests/cron/test_cron_no_agent.py+++ b/tests/cron/test_cron_no_agent.py@@ -242,9 +242,10 @@ def test_agent_provider_timeout_delivery_keeps_fallback_guidance(hermes_env, mon),)monkeypatch.setattr(- scheduler,- "_deliver_result",- lambda _job, content, **_kwargs: delivered.append(content),+ "cron.delivery_queue.enqueue",+ lambda execution_id, _job, content, **_kwargs: (+ delivered.append(content) or {"status": "pending"}+ ),)assert scheduler.run_one_job(job) is Truediff --git a/tests/cron/test_preflight_config.py b/tests/cron/test_preflight_config.pyindex 9fd39ea6d6e..70369186488 100644--- a/tests/cron/test_preflight_config.py+++ b/tests/cron/test_preflight_config.py@@ -127,7 +127,7 @@ class TestMissingProviderKeyBlocks:def test_single_alert_across_two_ticks_and_blocked_status(self, tmp_path):"""Two ticks of a blocked job through run_one_job deliver exactly ONEalert and persist last_status='blocked_config'."""- job = _job()+ job = _job(failure_deliver="slack:alerts")deliveries = []def fake_deliver(execution_id, job, content, **kwargs):@@ -229,7 +229,7 @@ class TestOptOut:(tmp_path / "config.yaml").write_text("cron:\n preflight: false\n", encoding="utf-8")- job = _job()+ job = _job(failure_deliver="slack:alerts")deliveries = []def fake_deliver(execution_id, job, content, **kwargs):diff --git a/tests/cron/test_sessiondb_init_hang.py b/tests/cron/test_sessiondb_init_hang.pyindex 8d7870da815..c2884f46218 100644--- a/tests/cron/test_sessiondb_init_hang.py+++ b/tests/cron/test_sessiondb_init_hang.py@@ -163,7 +163,7 @@ def test_guard_is_released_and_job_refires_after_sessiondb_hang(owner_run, monkeassert len(calls) == 2assert agent_cls.call_count == 1final_job = jobs.get_job(saved["id"])- assert final_job and final_job["last_status"] == "delivery_queued"+ assert final_job and final_job["last_status"] == "ok"finally:release.set()scheduler._shutdown_parallel_pool()