Skip to content

Commit 8171933

Browse files
authored
fix(heartbeat): qualify complete thin prompt capability routes (#7701)
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
1 parent b52103a commit 8171933

4 files changed

Lines changed: 64 additions & 4 deletions

File tree

‎docs/development/testing-and-quality.md‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1313,6 +1313,25 @@ fields; this does not introduce a new telemetry system or receipt gate.
13131313

13141314
### Budget Failure Decisions
13151315

1316+
The thin heartbeat's 4,500-character presentation allowance did not cover the
1317+
complete combination of a 320-character scope, all five runtime capability
1318+
flags, Codex App transport and an explicit CLI route. The existing public CLI
1319+
fixture with `/opt/loopx/qualified-tools/bin/loopx` emits 4,851 normalized body
1320+
characters at `a36e01c32`; its instructions and command arguments are complete.
1321+
Calibrate only this presentation allowance to 4,900, leaving 49 characters above
1322+
that input. Retain the original over-budget observation and add the complete
1323+
CLI combination plus an oversized-route negative case. Prompt text, capability
1324+
flags, the visible Goal's 4,000-character host limit, existing JSON/body fixture
1325+
ceilings, execution authority and frozen qualification results remain unchanged.
1326+
This corrects diagnostic coverage; it is not an output reduction or a claim of
1327+
model compliance, runtime recovery or lower cost.
1328+
1329+
薄提示原 4,500 字符展示预算未覆盖完整能力与显式 CLI 路由的组合;同一公开夹具
1330+
保留 320 字符 scope、五项能力和完整指令时为 4,851。仅将该展示预算校准为
1331+
4,900,保留原超限记录,并加入完整组合及更长路由仍超限的反例。正文、参数、
1332+
4,000 字符宿主硬边界、既有 JSON/正文夹具上限及执行权限不变;不据此声称节省
1333+
输出、恢复运行或改善模型行为。
1334+
13161335
The fixed visible-Goal host fixture's 3,200-character regression guard predates
13171336
`1d5d2d0f6`, which adds the known Todo choice to the first current guard. On the
13181337
same four host inputs at `b201da8ba`, substituting only the pre-change dispatch

‎loopx/control_plane/heartbeat/budget.py‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,10 @@
2323
# The same generic CLI + 320-char scope with explicit runtime also needs
2424
# 5,715 chars; retain those routes instead of shortening the instructions.
2525
"brief": 5_800,
26-
"thin": 4_500,
26+
# Full runtime capability flags plus an explicit CLI route and 320-char
27+
# scope emit 4,851 normalized chars with unchanged guidance. Keep that
28+
# supported combination; this is not a transport or execution limit.
29+
"thin": 4_900,
2730
"visible_goal": 4_000,
2831
}
2932
NATIVE_GOAL_HOST_MAX_CHARS = INTERFACE_BUDGET_CHARS["visible_goal"]

‎tests/control_plane/test_cli_output_budget.py‎

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1712,12 +1712,50 @@ def test_thin_json_budget_retains_full_supported_scope(tmp_path: Path) -> None:
17121712
)
17131713
payload = measurement["payload"]
17141714
assert scope in payload["task_body"]
1715-
assert payload["interface_budget"]["max_chars"] == 4500
1715+
assert payload["interface_budget"]["max_chars"] == 4900
17161716
assert payload["interface_budget"]["within_budget"] is True
17171717
assert "refresh-state --goal-outcome-update-json" in payload["task_body"]
17181718
assert "Local outcomes never replace root continuation, budget or stop criteria." in payload["task_body"]
17191719

17201720

1721+
@pytest.mark.parametrize("route_padding, within_budget", [("", True), ("x" * 48, False)])
1722+
def test_thin_budget_covers_complete_capability_and_cli_routes(
1723+
tmp_path: Path, route_padding: str, within_budget: bool,
1724+
) -> None:
1725+
# Exercise the actual CLI composition, not a shortened instruction or an
1726+
# estimated sum. An oversized route must still report a budget failure.
1727+
with _stable_budget_fixture_root(tmp_path) as root:
1728+
project, runtime, registry_path, state_file = _write_fixture(root, SCENARIOS[0])
1729+
import_fixture_authority(registry_path, GOAL_ID)
1730+
command = _surface_commands(
1731+
project=project, runtime=runtime, registry_path=registry_path,
1732+
state_file=state_file, output_format="json",
1733+
)["heartbeat_prompt_thin"]
1734+
scope = "x" * 320
1735+
command[command.index("--agent-scope") + 1] = scope
1736+
cli_route = f"/opt/loopx/{route_padding}qualified-tools/bin/loopx"
1737+
command.extend(["--codex-app", "--cli-bin", cli_route])
1738+
capabilities = ("shell", "filesystem", "network", "external_evidence_poll", "browser")
1739+
for capability in capabilities:
1740+
command.extend(["--available-capability", capability])
1741+
exit_code, text = _invoke_cli(command)
1742+
assert exit_code == 0, text
1743+
payload = json.loads(text)
1744+
body, budget = payload["task_body"], payload["interface_budget"]
1745+
assert scope in body and body.count(cli_route) >= 2
1746+
assert all(f"--available-capability {capability}" in body for capability in capabilities)
1747+
assert "--codex-app" in body and "--runtime-root" in body and "--registry" in body
1748+
assert "--todo-id <id>" in body and "settlement_plan.ordered_steps" in body
1749+
assert "ambiguous effects need readback/recovery, not blind retry" in body
1750+
assert "refresh-state --goal-outcome-update-json" in body
1751+
assert "Local outcomes never replace root continuation, budget or stop criteria." in body
1752+
# Preserve the historical 4,500-character failure as a characterized
1753+
# input; the allowance changes, not the complete emitted instructions.
1754+
assert budget["budget_char_count"] > 4500
1755+
assert budget["max_chars"] == 4900
1756+
assert budget["within_budget"] is within_budget
1757+
1758+
17211759
def test_brief_budget_retains_full_commands_on_real_long_paths() -> None:
17221760
# A reproducible 128-character absolute root; directory depth can still
17231761
# change JSON escaping cost. Keep full routes and this workload;

‎tests/control_plane/test_heartbeat_prompt_support.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ def test_native_profile_long_routes_retain_one_complete_settlement_contract() ->
9898

9999
@pytest.mark.parametrize("mode,limit", [
100100
("full", 13100), ("compact", 8000), ("brief", 5800),
101-
("thin", 4500), ("visible_goal", 4000),
101+
("thin", 4900), ("visible_goal", 4000),
102102
])
103103
def test_prompt_body_limit_remains_independent_of_json_envelope(mode: str, limit: int) -> None:
104104
for size in (limit, limit + 1):
@@ -356,7 +356,7 @@ 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", 5800), ("thin", 4500)],
359+
[("full", 13100), ("compact", 8000), ("brief", 5800), ("thin", 4900)],
360360
)
361361
@pytest.mark.parametrize("scope_chars", [0, 320])
362362
@pytest.mark.parametrize("runtime_profile", ["codex_app_heartbeat", "generic_cli"])

0 commit comments

Comments
 (0)