From c3165a81bb81b6082c8e80edac50c60dbbbbec77 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:07:41 +0800 Subject: [PATCH 1/3] fix(benchmark): refresh the host clock in heartbeat execution input Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- benchmark/README.md | 10 +++++ benchmark/runtime/planning.py | 42 ++++++++++------- benchmark/runtime/worker.py | 15 +++++++ .../tests/test_native_checkpoint_handoff.py | 8 ++++ benchmark/tests/test_task_entry.py | 45 +++++++++++++++++++ 5 files changed, 104 insertions(+), 16 deletions(-) diff --git a/benchmark/README.md b/benchmark/README.md index 15fc76cd7c..ec6569bbeb 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -806,6 +806,16 @@ through an authorized controller read route. The destination file must be new, outside the artifact and native bank, and installed at the Host's existing phase-file route before starting its ordinary entry command. +Heartbeat execution wakes now project the current caller-owned phase deadline, +observation time, remaining window, existing reserve, and wake execution limit +into model input. Planning and execution share the same renderer; a restored or +fresh session need not infer its budget from the initial planning message. +This changes heartbeat prompt context, not scoring, task acceptance, deadline +accounting, TurnEnvelope settings, or terminal authority. Plain, native-Goal, +Turn and loopx-goal execution inputs are unchanged. Without a phase clock the +heartbeat input is unchanged. A restored terminal Goal still requires explicit +resume through its owning contract; a newer clock alone does not reopen it. + The sealed deadline and native capture timestamp determine the remainder; the receiver recomputes it. A point with two hours remaining keeps that duration after an eight-hour offline gap. It does not reuse the old absolute epoch or diff --git a/benchmark/runtime/planning.py b/benchmark/runtime/planning.py index 5e4ffb2ca3..7aea7caf63 100644 --- a/benchmark/runtime/planning.py +++ b/benchmark/runtime/planning.py @@ -9,30 +9,40 @@ from pathlib import Path +def render_host_window(env: dict[str, str], *, execution_reserve_seconds: int, + wake_timeout_seconds: float | None = None) -> str: + """Project the caller's enforced clock; never create or extend an allowance.""" + key = "LOOPX_PHASE_DEADLINE_EPOCH" + if key not in env: + return "" + value = float(env[key]) + if not math.isfinite(value) or value <= 0: + raise ValueError(f"{key} must be finite and positive") + observed = time.time() + window = [ + f"Absolute phase deadline: {value} Unix UTC seconds.", + f"Remaining phase time at observation {observed}: {max(0, value - observed):.1f} seconds.", + f"Existing execution reserve: {execution_reserve_seconds} seconds. " + f"Observed work window before that reserve: {max(0, value - observed - execution_reserve_seconds):.1f} seconds.", + "This shared window includes planning and subsequent execution; " + "runtime startup and settlement reserves also consume it.", + ] + if wake_timeout_seconds is not None: + window.append(f"Current wake execution limit: {wake_timeout_seconds:.1f} seconds. " + "A wake limit is not the remaining phase budget.") + return "Host execution window:\n" + "\n".join(window) + "\n" + + def render_planning_prompt(packet: dict, env: dict[str, str], *, execution_reserve_seconds: int) -> str: """Project caller-owned clocks without changing the product planning packet.""" if "LOOPX_PLANNING_TIMEOUT_SEC" in env: raise ValueError( "Remove LOOPX_PLANNING_TIMEOUT_SEC; planning uses LOOPX_PHASE_DEADLINE_EPOCH" ) - window = [] - key = "LOOPX_PHASE_DEADLINE_EPOCH" - if key in env: - value = float(env[key]) - if not math.isfinite(value) or value <= 0: - raise ValueError(f"{key} must be finite and positive") - observed = time.time() - window.extend([ - f"Absolute phase deadline: {value} Unix UTC seconds.", - f"Remaining phase time at observation {observed}: {max(0, value - observed):.1f} seconds.", - f"Existing execution reserve: {execution_reserve_seconds} seconds. " - f"Observed work window before that reserve: {max(0, value - observed - execution_reserve_seconds):.1f} seconds.", - "This shared window includes planning and subsequent execution; " - "runtime startup and settlement reserves also consume it.", - ]) + window = render_host_window(env, execution_reserve_seconds=execution_reserve_seconds) prefix = "$loopx\n\n" if window: - prefix += "Host execution window:\n" + "\n".join(window) + "\n" + prefix += window prefix += ( "Use these observations to size the plan and its validation. They age " "as work proceeds; the runtime still enforces its original limits. " diff --git a/benchmark/runtime/worker.py b/benchmark/runtime/worker.py index c3f12d2055..6e2800af7b 100644 --- a/benchmark/runtime/worker.py +++ b/benchmark/runtime/worker.py @@ -434,6 +434,21 @@ def run_once(env: dict[str, str]) -> dict: from benchmark.runtime.checkpoint import capture_before_replan body = capture_before_replan(env, receipt, body) + if stage == "execute" and execution.mode == "heartbeat": + from benchmark.runtime.planning import render_host_window + + window = render_host_window(env, execution_reserve_seconds=PHASE_WORK_RESERVE_SECONDS, + wake_timeout_seconds=execution.timeout_seconds) + if window: + # Compose last so checkpoint preloading and fresh-session context + # both receive the current caller clock, not only the old plan. + body = window + ( + "This observation supersedes earlier host phase-window observations in session history. " + "It ages as work proceeds and grants no extra time. It does not reopen completed work " + "or override the current LoopX admission, settlement, stop conditions or task acceptance. " + "Use the current admitted contract to decide what work remains; do not infer Goal " + "completion from an expired historical clock.\n\n" + ) + body with (wake / "stderr.log").open("w") as stderr: if execution.native_goal and stage == "execute": run_native_goal(env, execution, body, receipt, stderr) diff --git a/benchmark/tests/test_native_checkpoint_handoff.py b/benchmark/tests/test_native_checkpoint_handoff.py index c56abcc2af..e88bc39970 100644 --- a/benchmark/tests/test_native_checkpoint_handoff.py +++ b/benchmark/tests/test_native_checkpoint_handoff.py @@ -700,11 +700,19 @@ def response(payload, index, message): LOOPX_CODEX_HOME=str(tmp_path / "worker-home"), LOOPX_SHARED_SKILLS=str(skills), MODEL_NAME="fixture", REASONING_EFFORT="high", OPENAI_BASE_URL=base_url, OPENAI_API_KEY="synthetic-local-only", LOOPX_CODEX_TURN_TIMEOUT_SEC="60") + deadline = str(time.time() + 600) + env["LOOPX_PHASE_DEADLINE_EPOCH"] = deadline if capture != "off": env["LOOPX_CHECKPOINT_REQUEST"] = str(request) result = run_once(env) assert result["ok"] and not result["timed_out"], result assert _heartbeat_receipt_count(runtime, TURN_ID) == 1 + # The real native transport sees the current clock after checkpoint + # preloading, while the unchanged guard retains decision authority. + worker_input = next(t for t in texts(requests[1]) if "quota should-run" in t and "```sh" in t) + assert f"Absolute phase deadline: {deadline}" in worker_input + assert "Current wake execution limit: 60.0 seconds" in worker_input + assert "does not reopen completed work" in worker_input if capture == "off": assert "checkpoint_handoffs" not in result assert "--decision-handoff-socket" not in guards[0] diff --git a/benchmark/tests/test_task_entry.py b/benchmark/tests/test_task_entry.py index 8a72e5887d..2cef39b621 100644 --- a/benchmark/tests/test_task_entry.py +++ b/benchmark/tests/test_task_entry.py @@ -747,3 +747,48 @@ async def no_pending(**kwargs): assert profile.get("stride_strategy", "off") == (strategy or "off") assert agent._replan_receipt() == {field: value, **({"stride_strategy": strategy} if strategy is not None else {})} + + +@pytest.mark.parametrize("context", ["fresh", "resume"]) +def test_execute_wake_receives_current_clock_after_planning(planning_env, context): + """Exercise the real worker/heartbeat CLI and capture its model transport input.""" + env = planning_env | {"LOOPX_ITERATION_CONTEXT": context} + assert run_once(env)["ok"] + binary = Path(env["CODEX_BIN"]) + binary.write_text( + f"#!{sys.executable}\n" + "import json, os, pathlib, sys\n" + "pathlib.Path(os.environ['CODEX_HOME'], 'execute-input.txt').write_text(sys.stdin.read())\n" + "print(json.dumps({'type': 'thread.started', 'thread_id': 'planning-fixture-session'}))\n" + ) + before = Path(env["LOOPX_REGISTRY"]).with_name("state.md").read_bytes() + old_deadline = env["LOOPX_PHASE_DEADLINE_EPOCH"] + for offset in [900, 500]: + deadline = str(time.time() + offset) + current = env | {"LOOPX_TASK_STAGE": "execute", + "LOOPX_PHASE_DEADLINE_EPOCH": deadline, + "LOOPX_CODEX_TURN_TIMEOUT_SEC": "120"} + receipt = run_once(current) + assert receipt["ok"] + body = (Path(env["LOOPX_CODEX_HOME"]) / "execute-input.txt").read_text() + assert f"Absolute phase deadline: {deadline}" in body + assert old_deadline not in body + assert "Current wake execution limit: 120.0 seconds" in body + assert "Existing execution reserve: 160 seconds" in body + assert "does not reopen completed work" in body + assert "heartbeat-prompt" in body or "quota" in body + assert receipt["session"]["action"] == ("resume" if context == "resume" else "start_new") + assert "turn_envelope" not in receipt + assert current["LOOPX_PHASE_DEADLINE_EPOCH"] == deadline + # A current clock changes model context, never task or completion authority. + assert Path(env["LOOPX_REGISTRY"]).with_name("state.md").read_bytes() == before + + +def test_execution_window_absence_and_shorter_wake_cap(): + from benchmark.runtime.planning import render_host_window + + assert render_host_window({}, execution_reserve_seconds=160) == "" + body = render_host_window({"LOOPX_PHASE_DEADLINE_EPOCH": "100"}, + execution_reserve_seconds=160, wake_timeout_seconds=12) + assert "Current wake execution limit: 12.0 seconds" in body + assert "Observed work window before that reserve: 0.0 seconds" in body From f08db4360062d1938eaa4df7395e648d448ee7c9 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:18:48 +0800 Subject: [PATCH 2/3] fix(benchmark): keep runtime countdowns out of model input Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- benchmark/README.md | 24 +++++--- benchmark/runtime/planning.py | 55 +++++++----------- benchmark/runtime/worker.py | 22 ++----- .../tests/test_native_checkpoint_handoff.py | 10 ++-- benchmark/tests/test_resume_sessions.py | 7 ++- benchmark/tests/test_task_entry.py | 58 +++++++------------ 6 files changed, 73 insertions(+), 103 deletions(-) diff --git a/benchmark/README.md b/benchmark/README.md index ec6569bbeb..fd16eff5a0 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -806,15 +806,21 @@ through an authorized controller read route. The destination file must be new, outside the artifact and native bank, and installed at the Host's existing phase-file route before starting its ordinary entry command. -Heartbeat execution wakes now project the current caller-owned phase deadline, -observation time, remaining window, existing reserve, and wake execution limit -into model input. Planning and execution share the same renderer; a restored or -fresh session need not infer its budget from the initial planning message. -This changes heartbeat prompt context, not scoring, task acceptance, deadline -accounting, TurnEnvelope settings, or terminal authority. Plain, native-Goal, -Turn and loopx-goal execution inputs are unchanged. Without a phase clock the -heartbeat input is unchanged. A restored terminal Goal still requires explicit -resume through its owning contract; a newer clock alone does not reopen it. +Planning and heartbeat execution inputs no longer project the Host's deadline, +remaining time, execution reserve or wake timeout to the model. The Host still +enforces the same finite budget and retains clocks in runtime state and receipts. +The model is guided to continue useful research from the original objective and +evidence, preserving validated results along the way. Task-defined time constraints +and evaluation cooldowns remain intact; this is not a general time-text filter. + +This changes model context, not scoring, task acceptance, deadline accounting, +TurnEnvelope settings or terminal authority. Plain, native-Goal, Turn and +loopx-goal execution inputs are unchanged. Existing session archives are not +rewritten: a new heartbeat explains that historical Host time-window messages +are not research deadlines or evidence of completion. A restored terminal Goal +still requires explicit resume through its owning contract. This adapter change +does not conceal clocks in accessible runtime files or guarantee model adoption; +compare pinned attempts to measure behavioral and outcome effects. The sealed deadline and native capture timestamp determine the remainder; the receiver recomputes it. A point with two hours remaining keeps that duration diff --git a/benchmark/runtime/planning.py b/benchmark/runtime/planning.py index 7aea7caf63..2d5649f09b 100644 --- a/benchmark/runtime/planning.py +++ b/benchmark/runtime/planning.py @@ -5,50 +5,35 @@ import json import math import subprocess -import time from pathlib import Path -def render_host_window(env: dict[str, str], *, execution_reserve_seconds: int, - wake_timeout_seconds: float | None = None) -> str: - """Project the caller's enforced clock; never create or extend an allowance.""" - key = "LOOPX_PHASE_DEADLINE_EPOCH" - if key not in env: - return "" - value = float(env[key]) - if not math.isfinite(value) or value <= 0: - raise ValueError(f"{key} must be finite and positive") - observed = time.time() - window = [ - f"Absolute phase deadline: {value} Unix UTC seconds.", - f"Remaining phase time at observation {observed}: {max(0, value - observed):.1f} seconds.", - f"Existing execution reserve: {execution_reserve_seconds} seconds. " - f"Observed work window before that reserve: {max(0, value - observed - execution_reserve_seconds):.1f} seconds.", - "This shared window includes planning and subsequent execution; " - "runtime startup and settlement reserves also consume it.", - ] - if wake_timeout_seconds is not None: - window.append(f"Current wake execution limit: {wake_timeout_seconds:.1f} seconds. " - "A wake limit is not the remaining phase budget.") - return "Host execution window:\n" + "\n".join(window) + "\n" +# The benchmark Host owns its runtime budget. Keep this guidance shared by +# planning and heartbeat wakes, including restored sessions with old clocks. +HOST_RUNTIME_GUIDANCE = ( + "The Host enforces runtime limits externally. Do not use historical host " + "time-window messages as a research deadline or evidence of Goal completion. " + "Continue useful research from the original objective and accumulated evidence " + "under the current admitted contract; preserve validated results as you go. " + "Task-defined constraints and evaluation rules still apply. This guidance " + "does not reopen completed work or override admission, settlement, stop " + "conditions or task acceptance.\n\n" +) -def render_planning_prompt(packet: dict, env: dict[str, str], *, execution_reserve_seconds: int) -> str: - """Project caller-owned clocks without changing the product planning packet.""" +def render_planning_prompt(packet: dict, env: dict[str, str]) -> str: + """Preserve the task packet without projecting the Host's execution clock.""" if "LOOPX_PLANNING_TIMEOUT_SEC" in env: raise ValueError( "Remove LOOPX_PLANNING_TIMEOUT_SEC; planning uses LOOPX_PHASE_DEADLINE_EPOCH" ) - window = render_host_window(env, execution_reserve_seconds=execution_reserve_seconds) - prefix = "$loopx\n\n" - if window: - prefix += window - prefix += ( - "Use these observations to size the plan and its validation. They age " - "as work proceeds; the runtime still enforces its original limits. " - "They grant no extra time or authority and do not relax task acceptance.\n\n" - ) - return prefix + "Host-supplied planning checkpoint:\n" + json.dumps(packet, ensure_ascii=False) + key = "LOOPX_PHASE_DEADLINE_EPOCH" + if key in env: + value = float(env[key]) + if not math.isfinite(value) or value <= 0: + raise ValueError(f"{key} must be finite and positive") + return ("$loopx\n\n" + HOST_RUNTIME_GUIDANCE + + "Host-supplied planning checkpoint:\n" + json.dumps(packet, ensure_ascii=False)) def task_plan_packet(env: dict[str, str], cli: list[str]) -> dict: diff --git a/benchmark/runtime/worker.py b/benchmark/runtime/worker.py index 6e2800af7b..8925361bc5 100644 --- a/benchmark/runtime/worker.py +++ b/benchmark/runtime/worker.py @@ -412,8 +412,7 @@ def run_once(env: dict[str, str]) -> dict: from benchmark.runtime.planning import render_planning_prompt, task_plan_packet planning_before = task_plan_packet(env, loopx_command(env)) - body = render_planning_prompt(planning_before, env, - execution_reserve_seconds=PHASE_WORK_RESERVE_SECONDS) + body = render_planning_prompt(planning_before, env) (wake / "planning-input.json").write_text(body, encoding="utf-8") (wake / "planning-schema.json").write_text(json.dumps(planning_before["result_schema"])) elif execution.mode in {"heartbeat", "loopx-goal"}: @@ -435,20 +434,11 @@ def run_once(env: dict[str, str]) -> dict: body = capture_before_replan(env, receipt, body) if stage == "execute" and execution.mode == "heartbeat": - from benchmark.runtime.planning import render_host_window - - window = render_host_window(env, execution_reserve_seconds=PHASE_WORK_RESERVE_SECONDS, - wake_timeout_seconds=execution.timeout_seconds) - if window: - # Compose last so checkpoint preloading and fresh-session context - # both receive the current caller clock, not only the old plan. - body = window + ( - "This observation supersedes earlier host phase-window observations in session history. " - "It ages as work proceeds and grants no extra time. It does not reopen completed work " - "or override the current LoopX admission, settlement, stop conditions or task acceptance. " - "Use the current admitted contract to decide what work remains; do not infer Goal " - "completion from an expired historical clock.\n\n" - ) + body + from benchmark.runtime.planning import HOST_RUNTIME_GUIDANCE + + # Compose last so checkpoint preloading and fresh-session context + # cannot leave a historical Host clock as the current instruction. + body = HOST_RUNTIME_GUIDANCE + body with (wake / "stderr.log").open("w") as stderr: if execution.native_goal and stage == "execute": run_native_goal(env, execution, body, receipt, stderr) diff --git a/benchmark/tests/test_native_checkpoint_handoff.py b/benchmark/tests/test_native_checkpoint_handoff.py index e88bc39970..b0b1a67439 100644 --- a/benchmark/tests/test_native_checkpoint_handoff.py +++ b/benchmark/tests/test_native_checkpoint_handoff.py @@ -707,11 +707,13 @@ def response(payload, index, message): result = run_once(env) assert result["ok"] and not result["timed_out"], result assert _heartbeat_receipt_count(runtime, TURN_ID) == 1 - # The real native transport sees the current clock after checkpoint - # preloading, while the unchanged guard retains decision authority. + # The real native transport receives continuation guidance after checkpoint + # preloading, while Host clocks and decision authority stay external. worker_input = next(t for t in texts(requests[1]) if "quota should-run" in t and "```sh" in t) - assert f"Absolute phase deadline: {deadline}" in worker_input - assert "Current wake execution limit: 60.0 seconds" in worker_input + assert deadline not in worker_input + assert "Absolute phase deadline" not in worker_input + assert "Current wake execution limit" not in worker_input + assert "Do not use historical host time-window messages" in worker_input assert "does not reopen completed work" in worker_input if capture == "off": assert "checkpoint_handoffs" not in result diff --git a/benchmark/tests/test_resume_sessions.py b/benchmark/tests/test_resume_sessions.py index c540b2ffb5..09ed4713a4 100644 --- a/benchmark/tests/test_resume_sessions.py +++ b/benchmark/tests/test_resume_sessions.py @@ -300,9 +300,10 @@ def log_message(self, *args): assert len(requests) == 2 history = json.dumps(requests[1]["input"]) assert "planning-input" in history and "planning-ack" in history - assert "Host execution window" in history - assert "Existing execution reserve: 160 seconds" in history - assert env["LOOPX_PHASE_DEADLINE_EPOCH"] in history + assert "Host execution window" not in history + assert "Existing execution reserve" not in history + assert env["LOOPX_PHASE_DEADLINE_EPOCH"] not in history + assert "Do not use historical host time-window messages" in history assert "Current Todo input." in history assert len(list((tmp_path / "logs/sessions").rglob("*.jsonl"))) == 1 finally: diff --git a/benchmark/tests/test_task_entry.py b/benchmark/tests/test_task_entry.py index 2cef39b621..96ee2ae32c 100644 --- a/benchmark/tests/test_task_entry.py +++ b/benchmark/tests/test_task_entry.py @@ -198,7 +198,7 @@ def test_prose_or_fabricated_todo_does_not_qualify_planning(planning_env): ) -def test_planner_receives_existing_phase_clock_without_changing_task_identity(planning_env): +def test_planner_keeps_host_clock_out_of_model_input_and_preserves_task_identity(planning_env): from benchmark.runtime.planning import task_plan_packet from benchmark.runtime.worker import loopx_command @@ -208,9 +208,9 @@ def test_planner_receives_existing_phase_clock_without_changing_task_identity(pl receipt = run_once(env) assert receipt["ok"] and receipt["planning"]["state_readback_verified"] body = next(Path(env["LOOPX_WAKE_LOG_DIR"]).glob("*/planning-input.json")).read_text() - assert deadline in body - assert "Host execution window" in body - assert "Existing execution reserve: 160 seconds" in body + assert deadline not in body + assert "Host execution window" not in body + assert "Existing execution reserve" not in body packet = json.loads(body.split("Host-supplied planning checkpoint:\n", 1)[1]) assert packet == before assert receipt["planning"]["input_digest"] == before["input_digest"] @@ -218,24 +218,18 @@ def test_planner_receives_existing_phase_clock_without_changing_task_identity(pl assert not list(Path(env["LOOPX_PROJECT"]).iterdir()) -def test_planning_window_uses_one_phase_deadline_and_preserves_packet(monkeypatch): - from benchmark.runtime import planning +def test_planning_input_is_clock_independent_but_preserves_task_time_constraints(): + from benchmark.runtime.planning import render_planning_prompt - monkeypatch.setattr(planning, "time", SimpleNamespace(time=lambda: 1000.0)) - packet = {"input_digest": "unchanged", "text": "保留原始任务"} - legacy = "$loopx\n\nHost-supplied planning checkpoint:\n" + json.dumps(packet, ensure_ascii=False) - assert planning.render_planning_prompt(packet, {}, execution_reserve_seconds=160) == legacy - env = {"LOOPX_PHASE_DEADLINE_EPOCH": "1600"} - body = planning.render_planning_prompt(packet, env, execution_reserve_seconds=160) - assert "Absolute phase deadline: 1600.0 Unix UTC seconds" in body - assert "Remaining phase time at observation 1000.0: 600.0 seconds" in body - assert "Observed work window before that reserve: 440.0 seconds" in body - assert "Planning invocation limit" not in body + packet = {"input_digest": "unchanged", "text": "Task constraint: inference under 30 seconds."} + body = render_planning_prompt(packet, {}) + for deadline in ["100", "1600", "9999999999"]: + env = {"LOOPX_PHASE_DEADLINE_EPOCH": deadline} + assert render_planning_prompt(packet, env) == body + assert env == {"LOOPX_PHASE_DEADLINE_EPOCH": deadline} assert json.loads(body.split("Host-supplied planning checkpoint:\n", 1)[1]) == packet - monkeypatch.setattr(planning, "time", SimpleNamespace(time=lambda: 1700.0)) - expired = planning.render_planning_prompt(packet, env, execution_reserve_seconds=160) - assert "Remaining phase time at observation 1700.0: 0.0 seconds" in expired - assert env == {"LOOPX_PHASE_DEADLINE_EPOCH": "1600"} + assert "Continue useful research" in body + assert "Task-defined constraints and evaluation rules still apply" in body @pytest.mark.parametrize("value", ["nan", "inf", "-inf", "0", "-1", "not-a-clock"]) @@ -244,7 +238,7 @@ def test_planning_window_rejects_invalid_host_clock(value): with pytest.raises(ValueError): render_planning_prompt({"input_digest": "unchanged"}, - {"LOOPX_PHASE_DEADLINE_EPOCH": value}, execution_reserve_seconds=160) + {"LOOPX_PHASE_DEADLINE_EPOCH": value}) def test_retired_planning_limit_fails_before_host_invocation(planning_env): @@ -750,7 +744,7 @@ async def no_pending(**kwargs): @pytest.mark.parametrize("context", ["fresh", "resume"]) -def test_execute_wake_receives_current_clock_after_planning(planning_env, context): +def test_execute_wake_keeps_host_clocks_out_of_fresh_and_resumed_input(planning_env, context): """Exercise the real worker/heartbeat CLI and capture its model transport input.""" env = planning_env | {"LOOPX_ITERATION_CONTEXT": context} assert run_once(env)["ok"] @@ -771,24 +765,16 @@ def test_execute_wake_receives_current_clock_after_planning(planning_env, contex receipt = run_once(current) assert receipt["ok"] body = (Path(env["LOOPX_CODEX_HOME"]) / "execute-input.txt").read_text() - assert f"Absolute phase deadline: {deadline}" in body + assert deadline not in body + assert "Absolute phase deadline" not in body assert old_deadline not in body - assert "Current wake execution limit: 120.0 seconds" in body - assert "Existing execution reserve: 160 seconds" in body + assert "Current wake execution limit" not in body + assert "Existing execution reserve" not in body + assert "Do not use historical host time-window messages" in body assert "does not reopen completed work" in body assert "heartbeat-prompt" in body or "quota" in body assert receipt["session"]["action"] == ("resume" if context == "resume" else "start_new") assert "turn_envelope" not in receipt assert current["LOOPX_PHASE_DEADLINE_EPOCH"] == deadline - # A current clock changes model context, never task or completion authority. + # Runtime clocks remain internal and never change task/completion authority. assert Path(env["LOOPX_REGISTRY"]).with_name("state.md").read_bytes() == before - - -def test_execution_window_absence_and_shorter_wake_cap(): - from benchmark.runtime.planning import render_host_window - - assert render_host_window({}, execution_reserve_seconds=160) == "" - body = render_host_window({"LOOPX_PHASE_DEADLINE_EPOCH": "100"}, - execution_reserve_seconds=160, wake_timeout_seconds=12) - assert "Current wake execution limit: 12.0 seconds" in body - assert "Observed work window before that reserve: 0.0 seconds" in body From 65671724168c7d639a983151136bfe4e50f15432 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Sat, 17 Oct 2026 01:29:40 +0800 Subject: [PATCH 3/3] refactor(benchmark): omit replacement host runtime guidance Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- benchmark/README.md | 28 +++++++++---------- benchmark/runtime/planning.py | 16 +---------- benchmark/runtime/worker.py | 6 ---- .../tests/test_native_checkpoint_handoff.py | 7 ++--- benchmark/tests/test_resume_sessions.py | 1 - benchmark/tests/test_task_entry.py | 6 ++-- 6 files changed, 19 insertions(+), 45 deletions(-) diff --git a/benchmark/README.md b/benchmark/README.md index fd16eff5a0..f4b756fc80 100644 --- a/benchmark/README.md +++ b/benchmark/README.md @@ -806,21 +806,19 @@ through an authorized controller read route. The destination file must be new, outside the artifact and native bank, and installed at the Host's existing phase-file route before starting its ordinary entry command. -Planning and heartbeat execution inputs no longer project the Host's deadline, -remaining time, execution reserve or wake timeout to the model. The Host still -enforces the same finite budget and retains clocks in runtime state and receipts. -The model is guided to continue useful research from the original objective and -evidence, preserving validated results along the way. Task-defined time constraints -and evaluation cooldowns remain intact; this is not a general time-text filter. - -This changes model context, not scoring, task acceptance, deadline accounting, -TurnEnvelope settings or terminal authority. Plain, native-Goal, Turn and -loopx-goal execution inputs are unchanged. Existing session archives are not -rewritten: a new heartbeat explains that historical Host time-window messages -are not research deadlines or evidence of completion. A restored terminal Goal -still requires explicit resume through its owning contract. This adapter change -does not conceal clocks in accessible runtime files or guarantee model adoption; -compare pinned attempts to measure behavioral and outcome effects. +Planning input no longer projects the Host's deadline, remaining time or +execution reserve to the model. The original task-planning packet is preserved; +no replacement Host runtime guidance is added to planning or execution wakes. +The Host still enforces its finite budget and retains clocks in runtime state +and receipts. Task-defined time constraints and evaluation cooldowns are unchanged. + +This is a planning prompt default change. Execution inputs, scoring, acceptance, +TurnEnvelope and terminal authority are unchanged. Old session archives may still +contain historical deadline messages: this change does not rewrite or neutralize +those messages. An authorized continuation must address stale context at its +restore boundary, and a terminal Goal still requires explicit resume. This PR +prevents new planning-clock injection; it does not qualify old-archive recovery +or claim improved model behavior or scores. The sealed deadline and native capture timestamp determine the remainder; the receiver recomputes it. A point with two hours remaining keeps that duration diff --git a/benchmark/runtime/planning.py b/benchmark/runtime/planning.py index 2d5649f09b..294838e2df 100644 --- a/benchmark/runtime/planning.py +++ b/benchmark/runtime/planning.py @@ -8,19 +8,6 @@ from pathlib import Path -# The benchmark Host owns its runtime budget. Keep this guidance shared by -# planning and heartbeat wakes, including restored sessions with old clocks. -HOST_RUNTIME_GUIDANCE = ( - "The Host enforces runtime limits externally. Do not use historical host " - "time-window messages as a research deadline or evidence of Goal completion. " - "Continue useful research from the original objective and accumulated evidence " - "under the current admitted contract; preserve validated results as you go. " - "Task-defined constraints and evaluation rules still apply. This guidance " - "does not reopen completed work or override admission, settlement, stop " - "conditions or task acceptance.\n\n" -) - - def render_planning_prompt(packet: dict, env: dict[str, str]) -> str: """Preserve the task packet without projecting the Host's execution clock.""" if "LOOPX_PLANNING_TIMEOUT_SEC" in env: @@ -32,8 +19,7 @@ def render_planning_prompt(packet: dict, env: dict[str, str]) -> str: value = float(env[key]) if not math.isfinite(value) or value <= 0: raise ValueError(f"{key} must be finite and positive") - return ("$loopx\n\n" + HOST_RUNTIME_GUIDANCE + - "Host-supplied planning checkpoint:\n" + json.dumps(packet, ensure_ascii=False)) + return "$loopx\n\nHost-supplied planning checkpoint:\n" + json.dumps(packet, ensure_ascii=False) def task_plan_packet(env: dict[str, str], cli: list[str]) -> dict: diff --git a/benchmark/runtime/worker.py b/benchmark/runtime/worker.py index 8925361bc5..4a7cc3a9fc 100644 --- a/benchmark/runtime/worker.py +++ b/benchmark/runtime/worker.py @@ -433,12 +433,6 @@ def run_once(env: dict[str, str]) -> dict: from benchmark.runtime.checkpoint import capture_before_replan body = capture_before_replan(env, receipt, body) - if stage == "execute" and execution.mode == "heartbeat": - from benchmark.runtime.planning import HOST_RUNTIME_GUIDANCE - - # Compose last so checkpoint preloading and fresh-session context - # cannot leave a historical Host clock as the current instruction. - body = HOST_RUNTIME_GUIDANCE + body with (wake / "stderr.log").open("w") as stderr: if execution.native_goal and stage == "execute": run_native_goal(env, execution, body, receipt, stderr) diff --git a/benchmark/tests/test_native_checkpoint_handoff.py b/benchmark/tests/test_native_checkpoint_handoff.py index b0b1a67439..edb585ba28 100644 --- a/benchmark/tests/test_native_checkpoint_handoff.py +++ b/benchmark/tests/test_native_checkpoint_handoff.py @@ -707,14 +707,13 @@ def response(payload, index, message): result = run_once(env) assert result["ok"] and not result["timed_out"], result assert _heartbeat_receipt_count(runtime, TURN_ID) == 1 - # The real native transport receives continuation guidance after checkpoint - # preloading, while Host clocks and decision authority stay external. + # Checkpoint preloading keeps the existing heartbeat contract without + # injecting a Host countdown or runtime guidance. worker_input = next(t for t in texts(requests[1]) if "quota should-run" in t and "```sh" in t) assert deadline not in worker_input assert "Absolute phase deadline" not in worker_input assert "Current wake execution limit" not in worker_input - assert "Do not use historical host time-window messages" in worker_input - assert "does not reopen completed work" in worker_input + assert "The Host enforces runtime limits externally" not in worker_input if capture == "off": assert "checkpoint_handoffs" not in result assert "--decision-handoff-socket" not in guards[0] diff --git a/benchmark/tests/test_resume_sessions.py b/benchmark/tests/test_resume_sessions.py index 09ed4713a4..66e8d78aab 100644 --- a/benchmark/tests/test_resume_sessions.py +++ b/benchmark/tests/test_resume_sessions.py @@ -303,7 +303,6 @@ def log_message(self, *args): assert "Host execution window" not in history assert "Existing execution reserve" not in history assert env["LOOPX_PHASE_DEADLINE_EPOCH"] not in history - assert "Do not use historical host time-window messages" in history assert "Current Todo input." in history assert len(list((tmp_path / "logs/sessions").rglob("*.jsonl"))) == 1 finally: diff --git a/benchmark/tests/test_task_entry.py b/benchmark/tests/test_task_entry.py index 96ee2ae32c..592a7327f0 100644 --- a/benchmark/tests/test_task_entry.py +++ b/benchmark/tests/test_task_entry.py @@ -228,8 +228,7 @@ def test_planning_input_is_clock_independent_but_preserves_task_time_constraints assert render_planning_prompt(packet, env) == body assert env == {"LOOPX_PHASE_DEADLINE_EPOCH": deadline} assert json.loads(body.split("Host-supplied planning checkpoint:\n", 1)[1]) == packet - assert "Continue useful research" in body - assert "Task-defined constraints and evaluation rules still apply" in body + assert body == "$loopx\n\nHost-supplied planning checkpoint:\n" + json.dumps(packet, ensure_ascii=False) @pytest.mark.parametrize("value", ["nan", "inf", "-inf", "0", "-1", "not-a-clock"]) @@ -770,8 +769,7 @@ def test_execute_wake_keeps_host_clocks_out_of_fresh_and_resumed_input(planning_ assert old_deadline not in body assert "Current wake execution limit" not in body assert "Existing execution reserve" not in body - assert "Do not use historical host time-window messages" in body - assert "does not reopen completed work" in body + assert "The Host enforces runtime limits externally" not in body assert "heartbeat-prompt" in body or "quota" in body assert receipt["session"]["action"] == ("resume" if context == "resume" else "start_new") assert "turn_envelope" not in receipt