diff --git a/cron/scheduler.py b/cron/scheduler.py index 5924ba19e6..32b351aa04 100644 --- a/cron/scheduler.py +++ b/cron/scheduler.py @@ -685,22 +685,14 @@ def _build_job_prompt(job: dict, prerun_script: Optional[tuple] = None) -> str: try: job_output_dir = OUTPUT_DIR / source_job_id if not job_output_dir.exists(): - prompt = ( - f"[Context job '{source_job_id}' has no output yet.]\n\n" - f"{prompt}" - ) - continue + continue # silent skip — no output yet output_files = sorted( job_output_dir.glob("*.md"), key=lambda f: f.stat().st_mtime, reverse=True, ) if not output_files: - prompt = ( - f"[Context job '{source_job_id}' has no output yet.]\n\n" - f"{prompt}" - ) - continue + continue # silent skip — no output yet latest_output = output_files[0].read_text(encoding="utf-8").strip() # Truncate to 8K characters to avoid prompt bloat _MAX_CONTEXT_CHARS = 8000 @@ -715,16 +707,10 @@ def _build_job_prompt(job: dict, prerun_script: Optional[tuple] = None) -> str: f"{prompt}" ) else: - prompt = ( - f"[Context job '{source_job_id}' has no output yet.]\n\n" - f"{prompt}" - ) + continue # silent skip — empty output except (OSError, PermissionError) as e: logger.warning("context_from: failed to read output for job %r: %s", source_job_id, e) - prompt = ( - f"[Context job '{source_job_id}' output could not be read.]\n\n" - f"{prompt}" - ) + # silent skip — do not pollute the prompt with error messages # Always prepend cron execution guidance so the agent knows how # delivery works and can suppress delivery when appropriate. diff --git a/tests/cron/test_cron_context_from.py b/tests/cron/test_cron_context_from.py index 014a8d7aa7..e3103f76fe 100644 --- a/tests/cron/test_cron_context_from.py +++ b/tests/cron/test_cron_context_from.py @@ -132,9 +132,11 @@ class TestBuildJobPromptContextFrom: prompt="Summarize", schedule="every 2h", context_from=job_a["id"] ) - # job_a ещё не запускался — output dir не существует + # job_a never ran — output dir does not exist + # expect silent skip: no placeholder injected, base prompt intact prompt = _build_job_prompt(job_b) - assert "no output yet" in prompt.lower() or "not found" in prompt.lower() + assert "no output" not in prompt.lower() + assert "not found" not in prompt.lower() assert "Summarize" in prompt def test_injects_multiple_context_jobs(self, cron_env):