Skip to content

The agent that grows with you

refactor(cron): build run documents from the shared frame constants

kshitijk4poordad9c567482c
diff --git a/cron/scheduler.py b/cron/scheduler.py
index bb9439a433c..2a6def9697a 100644
--- a/cron/scheduler.py
+++ b/cron/scheduler.py
@@ -2166,7 +2166,7 @@ def _run_doc_header(job: dict, title: str, job_id: str, prompt: str, *, prompt_s
f"**Job ID:** {job_id}\n"
f"**Run Time:** {_hermes_now().strftime('%Y-%m-%d %H:%M:%S')}\n"
f"**Schedule:** {job.get('schedule_display', 'N/A')}\n\n"
- f"{prompt_stamp}## Prompt\n\n{prompt}\n\n"
+ f"{prompt_stamp}{_PROMPT_HEADING}{prompt}{_PROMPT_SEPARATOR}"
)
@@ -2551,8 +2551,7 @@ def run_job(
output = (
_run_doc_header(job, job_name, job_id, framed_prompt,
prompt_stamp=f"{_PROMPT_FRAME}{len(framed_prompt)}\n")
- + f"{_RESPONSE_FRAME}{len(logged_response)}\n## Response\n\n"
- + f"{logged_response}\n"
+ + f"{_RESPONSE_FRAME}{len(logged_response)}\n{_RESPONSE_HEADING}{logged_response}{_RESPONSE_TERMINATOR}"
)
logger.info("Job '%s' completed successfully", job_name)
_audit.write(dict(result, response_silent=_is_cron_silence_response(final_response or "")), None)
@@ -4295,8 +4294,9 @@ from cron.scheduler_script import ( # noqa: E402
_get_session_db_timeout, _run_job_script_with_claim_heartbeat, _start_heartbeat_thread,
)
from cron.scheduler_prompt import ( # noqa: E402
- _PROMPT_FRAME, _RESPONSE_FRAME, _block_and_pause_job, _build_job_prompt,
- _guard_job_credential_exfil, _parse_wake_gate,
+ _PROMPT_FRAME, _PROMPT_HEADING, _PROMPT_SEPARATOR, _RESPONSE_FRAME, _RESPONSE_HEADING,
+ _RESPONSE_TERMINATOR, _block_and_pause_job, _build_job_prompt, _guard_job_credential_exfil,
+ _parse_wake_gate,
)
from cron.scheduler_preflight import ( # noqa: E402
BLOCKED_CONFIG_MARKER, BLOCKED_CONFIG_SILENT_MARKER, _cron_preflight_enabled,
diff --git a/cron/scheduler_prompt.py b/cron/scheduler_prompt.py
index 98f2497b456..48d36bd09bb 100644
--- a/cron/scheduler_prompt.py
+++ b/cron/scheduler_prompt.py
@@ -165,7 +165,7 @@ def _inject_context_from(job: dict, prompt: str) -> tuple[str, bool]:
"Script gate returned `wakeAgent=false`"))
for line in header.splitlines()
)
- if not candidate or candidate.isspace() or silent_audit:
+ if not candidate.strip() or silent_audit:
continue
answer = _archive_answer(candidate)
if answer is None:
diff --git a/tests/cron/test_context_from_response_extraction.py b/tests/cron/test_context_from_response_extraction.py
index a86bfb4e983..f2dbf26bb6a 100644
--- a/tests/cron/test_context_from_response_extraction.py
+++ b/tests/cron/test_context_from_response_extraction.py
@@ -128,7 +128,6 @@ def test_writer_reader_preserve_response_with_nested_frames(cron_env, monkeypatc
schedule="0 8 * * *", context_from="self")
success, archive, final, error = _run_stub_job(monkeypatch, job, answer)
assert success, error
- assert final == answer
save_job_output(job["id"], archive)
prompt, injected = _inject_context_from(job, "Next task")
assert injected
@@ -150,7 +149,6 @@ def test_truncated_outer_frame_cannot_promote_a_quoted_inner_frame(cron_env, mon
job = create_job(prompt="Report", schedule="0 8 * * *", context_from="self")
success, archive, final, error = _run_stub_job(monkeypatch, job, answer)
assert success, error
- assert final == answer
save_job_output(job["id"], archive)
saved = next((OUTPUT_DIR / job["id"]).glob("*.md"))
complete = saved.read_text(encoding="utf-8")