From 0eda2ba0c83501c3b478869cac5ebd47a2f520cf Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Mon, 24 Aug 2026 15:25:28 +0530 Subject: [PATCH] fix: remove dead code, deduplicate error constants, fix skill key check Follow-up to PR #92189 salvage: - Remove unused job_no_agent_without_script() function (dead code) - Replace inline NO_AGENT_WITHOUT_SCRIPT_ERROR string in _validate_job_mode_invariants with the constant - Replace scheduler inline reason string with EMPTY_PAYLOAD_ERROR constant - Add 'skill' (singular) to job_payload_is_empty 'in job' presence check --- cron/jobs.py | 15 ++------------- cron/scheduler.py | 4 ++-- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/cron/jobs.py b/cron/jobs.py index 1e305103fd..173034f7c7 100644 --- a/cron/jobs.py +++ b/cron/jobs.py @@ -523,14 +523,6 @@ NO_AGENT_WITHOUT_SCRIPT_ERROR = ( ) -def job_no_agent_without_script(job: Dict[str, Any]) -> bool: - """True when a job record claims ``no_agent`` but has no usable script. - - The script IS the job in no_agent mode, so this shape can never run. - """ - return bool(job.get("no_agent")) and not _coerce_job_text(job.get("script")).strip() - - def job_payload_is_empty(job: Dict[str, Any]) -> bool: """True when a job record has nothing runnable at all. @@ -545,7 +537,7 @@ def job_payload_is_empty(job: Dict[str, Any]) -> bool: if _normalize_skill_list(job.get("skill"), job.get("skills")): return False # Only flag if at least one payload field is explicitly present in the record - if "prompt" in job or "script" in job or "skills" in job: + if "prompt" in job or "script" in job or "skill" in job or "skills" in job: return True return False @@ -1917,10 +1909,7 @@ def _validate_job_mode_invariants( "based on source changes. Use a plain no_agent script job instead." ) if no_agent and not script: - raise ValueError( - "no_agent=True requires a script — with no agent and no script " - "there is nothing for the job to run." - ) + raise ValueError(NO_AGENT_WITHOUT_SCRIPT_ERROR) def create_job( diff --git a/cron/scheduler.py b/cron/scheduler.py index 1c80add037..e4498ad34f 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -5225,13 +5225,13 @@ def run_job( # otherwise wake the LLM with an empty instruction on every fire. Pause # the job so it stops being scheduled, and never construct the agent. # --------------------------------------------------------------- - from cron.jobs import job_payload_is_empty + from cron.jobs import EMPTY_PAYLOAD_ERROR, job_payload_is_empty if job_payload_is_empty(job): return _block_and_pause_job( job_id, job_name, - "Cron job has nothing to run: prompt is blank and no script or skills are set", + EMPTY_PAYLOAD_ERROR, ) # ---------------------------------------------------------------