diff --git a/tests/cron/test_scheduler.py b/tests/cron/test_scheduler.py index 76314f8324e51..288610165601c 100644 --- a/tests/cron/test_scheduler.py +++ b/tests/cron/test_scheduler.py @@ -1936,6 +1936,30 @@ class TestMultiTargetDeliveryContinuesOnFailure: assert "b@example.com" in result assert mock_pool.submit.call_count == 2 +class TestBuildJobPromptExtraPrompt: + """Regression: _build_job_prompt merges extra_prompt into the assembled prompt.""" + + def test_extra_prompt_appended_with_header(self): + """extra_prompt appears under a '## Run Context' header.""" + job = {"prompt": "stored prompt"} + result = _build_job_prompt(job, extra_prompt="CONTEXT: client=Foo") + assert "stored prompt" in result + assert "## Run Context" in result + assert "CONTEXT: client=Foo" in result + + def test_extra_prompt_does_not_mutate_job(self): + """The job dict's 'prompt' field must remain unchanged.""" + job = {"prompt": "original"} + _build_job_prompt(job, extra_prompt="transient context") + assert job["prompt"] == "original" + + def test_no_extra_prompt_omits_header(self): + """Without extra_prompt, no '## Run Context' header is injected.""" + job = {"prompt": "just the stored prompt"} + result = _build_job_prompt(job) + assert "## Run Context" not in result + assert "just the stored prompt" in result + class TestSetCronSessionTitle: """Robust cron session titling: #50535/#50536/#50537."""