From 89db3aeb2caa19424fcc1d842be82f045d2d1a90 Mon Sep 17 00:00:00 2001 From: Teknium <127238744+teknium1@users.noreply.github.com> Date: Sun, 5 Apr 2026 23:58:45 -0700 Subject: [PATCH] =?UTF-8?q?fix(cron):=20add=20delivery=20guidance=20to=20c?= =?UTF-8?q?ron=20prompt=20=E2=80=94=20stop=20send=5Fmessage=20thrashing=20?= =?UTF-8?q?(#5444)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cron agents were burning iterations trying to use send_message (which is disabled via messaging toolset) because their prompts said things like 'send the report to Telegram'. The scheduler handles delivery automatically via the deliver setting, but nothing told the agent that. Add a delivery guidance hint to _build_job_prompt alongside the existing [SILENT] hint: tells agents their final response is auto-delivered and they should NOT use send_message. Before: only [SILENT] suppression hint After: delivery guidance ('do NOT use send_message') + [SILENT] hint --- cron/scheduler.py | 19 +++++++++++-------- tests/cron/test_scheduler.py | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/cron/scheduler.py b/cron/scheduler.py index 2337c25a5..c2f52be0e 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -383,17 +383,20 @@ def _build_job_prompt(job: dict) -> str: f"{prompt}" ) - # Always prepend [SILENT] guidance so the cron agent can suppress - # delivery when it has nothing new or noteworthy to report. - silent_hint = ( - "[SYSTEM: If you have a meaningful status report or findings, " - "send them — that is the whole point of this job. Only respond " - "with exactly \"[SILENT]\" (nothing else) when there is genuinely " - "nothing new to report. [SILENT] suppresses delivery to the user. " + # Always prepend cron execution guidance so the agent knows how + # delivery works and can suppress delivery when appropriate. + cron_hint = ( + "[SYSTEM: You are running as a scheduled cron job. " + "DELIVERY: Your final response will be automatically delivered " + "to the user — do NOT use send_message or try to deliver " + "the output yourself. Just produce your report/output as your " + "final response and the system handles the rest. " + "SILENT: If there is genuinely nothing new to report, respond " + "with exactly \"[SILENT]\" (nothing else) to suppress delivery. " "Never combine [SILENT] with content — either report your " "findings normally, or say [SILENT] and nothing more.]\n\n" ) - prompt = silent_hint + prompt + prompt = cron_hint + prompt if skills is None: legacy = job.get("skill") skills = [legacy] if legacy else [] diff --git a/tests/cron/test_scheduler.py b/tests/cron/test_scheduler.py index 06df5c351..00531d3c1 100644 --- a/tests/cron/test_scheduler.py +++ b/tests/cron/test_scheduler.py @@ -730,6 +730,21 @@ class TestBuildJobPromptSilentHint: result = _build_job_prompt(job) assert "[SILENT]" in result + def test_delivery_guidance_present(self): + """Cron hint tells agents their final response is auto-delivered.""" + job = {"prompt": "Generate a report"} + result = _build_job_prompt(job) + assert "do NOT use send_message" in result + assert "automatically delivered" in result + + def test_delivery_guidance_precedes_user_prompt(self): + """System guidance appears before the user's prompt text.""" + job = {"prompt": "My custom prompt"} + result = _build_job_prompt(job) + system_pos = result.index("do NOT use send_message") + prompt_pos = result.index("My custom prompt") + assert system_pos < prompt_pos + class TestBuildJobPromptMissingSkill: """Verify that a missing skill logs a warning and does not crash the job."""