fix(cron): thread per-run prompt through cronjob(action='run') (#57331)
Salvaged from PR #57342 by @liuhao1024 (with the injection-scan half from PR #57360 by @ghedeselmabot): cronjob(action='run', prompt=...) silently discarded the prompt argument — per-run context never reached the spawned cron session. The prompt is now threaded as extra_prompt through the whole chain (cronjob run action → _try_dispatch_background_run/_execute_job_now → _run_claimed_job → run_one_job → run_job → _build_job_prompt) and appended to the stored prompt under a '## Run Context' header for that single fire only — never persisted to the job definition. It passes the same strict _scan_cron_prompt injection scan as stored prompts before firing, and works identically on the background and sync fallback paths. Test fakes across tests/cron/ updated to accept the new kwargs (sibling-test blast radius from the signature change). Co-authored-by: liuhao1024 <liuhao1024@users.noreply.github.com>
This commit is contained in:
@@ -1268,7 +1268,7 @@ class TestParallelTick:
|
||||
barrier = threading.Barrier(2, timeout=5)
|
||||
call_order = []
|
||||
|
||||
def mock_run_job(job, *, defer_agent_teardown=None):
|
||||
def mock_run_job(job, *, defer_agent_teardown=None, **kw):
|
||||
"""Each job hits a barrier — both must be active simultaneously."""
|
||||
call_order.append(("start", job["id"]))
|
||||
barrier.wait() # blocks until both threads reach here
|
||||
@@ -1302,7 +1302,7 @@ class TestParallelTick:
|
||||
from gateway.session_context import get_session_env
|
||||
seen = {}
|
||||
|
||||
def mock_run_job(job, *, defer_agent_teardown=None):
|
||||
def mock_run_job(job, *, defer_agent_teardown=None, **kw):
|
||||
origin = job.get("origin", {})
|
||||
# run_job sets ContextVars — verify each job sees its own
|
||||
from gateway.session_context import set_session_vars, clear_session_vars
|
||||
|
||||
Reference in New Issue
Block a user