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
This commit is contained in:
kshitijk4poor
2026-08-24 15:25:28 +05:30
committed by kshitij
parent 350fb975b9
commit 0eda2ba0c8
2 changed files with 4 additions and 15 deletions
+2 -13
View File
@@ -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(
+2 -2
View File
@@ -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,
)
# ---------------------------------------------------------------