Skip to content

Commit b76b333

Browse files
loopx-agenthuangruiteng
authored andcommitted
test(heartbeat): align timed-wait budget and obligation consumers
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
1 parent 7a2421e commit b76b333

5 files changed

Lines changed: 32 additions & 18 deletions

File tree

‎loopx/control_plane/heartbeat/budget.py‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@
1717
# original settlement and fresh admission rather than abbreviating them.
1818
"full": 13_100,
1919
"compact": 8_000,
20-
"brief": 5_700,
20+
# The same generic CLI + 320-char scope with explicit runtime also needs
21+
# 5,715 chars; retain those routes instead of shortening the instructions.
22+
"brief": 5_800,
2123
"thin": 4_500,
2224
"visible_goal": 4_000,
2325
}

‎tests/control_plane/test_heartbeat_brief_budget.py‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,11 @@ def test_brief_keeps_complete_routes_with_128_character_windows_root() -> None:
108108
"preserve exact identities/effect ids and actual outcomes",
109109
"Never reconstruct static refresh/spend; ambiguous effects need readback/recovery, not blind retry",
110110
"Todo done≠Turn settled; no invented successor/--no-follow-up",
111-
"No wait spend",
111+
"No useful independent work before an evidenced due time",
112+
"--status deferred --resume-when resume_at:",
113+
"settle original Turn, then yield to host scheduler",
114+
"Fresh admission on resume",
115+
"No spend for waiting alone",
112116
"Finish Goal only on terminal no-follow-up",
113117
"Destructive Git/production requires explicit authorization",
114118
):

‎tests/control_plane/test_heartbeat_envelope_transport.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,13 @@ def test_capture_preserves_full_dispatcher_and_envelope_needs_explicit_opt_in(tm
8282
no_memory = dict(args, reward_memory_enabled=False)
8383
ordinary = build_heartbeat_prompt(**no_memory)
8484
captured_only = build_heartbeat_prompt(**no_memory, decision_output_root=tmp_path)
85-
assert ordinary['interface_budget']['max_chars'] == 4_200
86-
assert captured_only['interface_budget']['max_chars'] == 4_200
85+
assert ordinary['interface_budget']['max_chars'] == 4_500
86+
assert captured_only['interface_budget']['max_chars'] == 4_500
8787
oversized = build_heartbeat_prompt(
8888
**no_memory, decision_output_root=tmp_path, turn_envelope=True,
8989
agent_scopes=[letter * 320 for letter in 'stu'],
9090
)
91-
assert oversized['interface_budget']['max_chars'] == 4_600
91+
assert oversized['interface_budget']['max_chars'] == 4_900
9292
assert oversized['interface_budget']['within_budget'] is False
9393
for overrides in (dict(turn_instance_id=None), dict(thin=False, full=True),
9494
dict(runtime_profile='codex_app_ssh_goal')):
@@ -163,7 +163,7 @@ def test_bound_captured_prompt_fits_budget_without_reward_memory(
163163
assert '--reward-memory-reflection-json' not in body
164164
assert str(runtime) in body and str(capture) in body
165165
assert payload['turn_instance_id'] == TURN_ID
166-
assert payload['interface_budget']['max_chars'] == 4_600
166+
assert payload['interface_budget']['max_chars'] == 4_900
167167
assert payload['interface_budget']['within_budget'], payload['interface_budget']
168168
assert len(result.stdout) <= 5_400 # Shipped Agent JSON, not generator metadata.
169169
assert 'using inline ACK argv' in body

‎tests/control_plane/test_heartbeat_notification_rule.py‎

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,15 @@ def test_todo_closeout_does_not_invent_successors_or_skip_turn_settlement(tmp_pa
127127
assert "no invented successor" in body
128128
assert "settlement_plan" in body
129129
assert "projected monitor/continuation" in body
130-
assert "keep open" in body or "Wait=open" in body
131-
assert "no wait spend" in body.lower()
132-
assert "continue only admitted work" in body or "admitted P1/P2" in body
130+
assert "No useful independent work before an evidenced due time" in body
131+
assert "--status deferred --resume-when resume_at:" in body
132+
assert "settle original Turn, then yield to host scheduler" in body
133+
assert "Fresh admission on resume" in body
134+
assert "No spend for waiting alone" in body
135+
assert "continue only admitted work" in body.lower() or "admitted P1/P2" in body
133136
for stale in ("Done -> successor first", "Done->successor",
134137
"open + monitor_changed + successor", "wait->monitor+successor/work",
135-
"no-follow-up completion"):
138+
"no-follow-up completion", "Wait=open"):
136139
assert stale not in body
137140

138141

@@ -212,9 +215,9 @@ def test_language_policy_preserves_blocker_and_native_goal_continuation() -> Non
212215
brief = " ".join(render_brief_heartbeat_task_body(**kwargs).split())
213216
assert "settlement_plan.ordered_steps" in brief
214217
assert "preserve exact identities/effect ids and actual outcomes" in brief
215-
assert "Wait: keep open; follow projected monitor/continuation" in brief
216-
assert "continue only admitted work" in brief
217-
assert "No wait spend" in brief
218+
assert "Other waits: projected monitor/continuation" in brief
219+
assert "continue only admitted work" in brief.lower()
220+
assert "No spend for waiting alone" in brief
218221
assert "Finish Goal only on terminal no-follow-up" in brief
219222

220223
for renderer in (

‎tests/control_plane/test_heartbeat_prompt_support.py‎

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ def test_native_profile_long_routes_retain_one_complete_settlement_contract() ->
9797

9898

9999
@pytest.mark.parametrize("mode,limit", [
100-
("full", 13100), ("compact", 8000), ("brief", 5700),
100+
("full", 13100), ("compact", 8000), ("brief", 5800),
101101
("thin", 4500), ("visible_goal", 4000),
102102
])
103103
def test_prompt_body_limit_remains_independent_of_json_envelope(mode: str, limit: int) -> None:
@@ -356,19 +356,23 @@ def test_brief_diagnostics_keep_only_the_selected_prompt_command() -> None:
356356

357357
@pytest.mark.parametrize(
358358
("mode", "base_budget"),
359-
[("full", 13100), ("compact", 8000), ("brief", 5700), ("thin", 4500)],
359+
[("full", 13100), ("compact", 8000), ("brief", 5800), ("thin", 4500)],
360360
)
361361
@pytest.mark.parametrize("scope_chars", [0, 320])
362+
@pytest.mark.parametrize("runtime_profile", ["codex_app_heartbeat", "generic_cli"])
363+
@pytest.mark.parametrize("explicit_route", [False, True])
362364
def test_reward_memory_prompt_headroom_is_fixed_and_feature_scoped(
363-
mode: str, base_budget: int, scope_chars: int
365+
mode: str, base_budget: int, scope_chars: int, runtime_profile: str, explicit_route: bool,
364366
) -> None:
365367
profile = {"scope_summary": "x" * scope_chars} if scope_chars else None
368+
route = {"registry_path": "/fixture/registry.json", "runtime_root": "/fixture/runtime"} if explicit_route else {}
366369
enabled = build_heartbeat_prompt(
367370
goal_id="reward-memory-budget-fixture",
368371
agent_id="worker-a",
369372
registered_agents=["worker-a"],
370373
agent_profile=profile,
371-
runtime_profile="codex_app_heartbeat",
374+
runtime_profile=runtime_profile,
375+
**route,
372376
**{mode: True},
373377
reward_memory_enabled=True,
374378
)
@@ -377,7 +381,8 @@ def test_reward_memory_prompt_headroom_is_fixed_and_feature_scoped(
377381
agent_id="worker-a",
378382
registered_agents=["worker-a"],
379383
agent_profile=profile,
380-
runtime_profile="codex_app_heartbeat",
384+
runtime_profile=runtime_profile,
385+
**route,
381386
**{mode: True},
382387
reward_memory_enabled=False,
383388
)

0 commit comments

Comments
 (0)