Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions loopx/control_plane/heartbeat/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,14 @@ def build_heartbeat_prompt(
):
if not payload.get(key):
payload.pop(key, None)
elif brief:
# The brief task body already embeds its compact-detail command. Keep
# only the selected brief command as top-level regeneration metadata;
# repeating the other mode commands can exceed the registered output
# budget when the CLI/runtime paths are long.
payload.pop("expanded_prompt_command", None)
payload.pop("compact_prompt_command", None)
payload.pop("thin_prompt_command", None)
return payload
def build_heartbeat_prompt_error_payload(
*,
Expand Down
23 changes: 18 additions & 5 deletions loopx/control_plane/heartbeat/task_body.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,13 +741,26 @@ def render_heartbeat_generator_inputs_markdown(payload: dict[str, Any]) -> str:
f"- agent_model: `{payload.get('agent_model')}`",
f"- agent_role: `{payload.get('agent_role')}`",
]
lines.append(f"- agent_scopes: `{payload.get('agent_scopes')}`")
if payload.get("thin") is True:
lines.append(
f"- thin_prompt_command: `{payload.get('thin_prompt_command')}`"
)
elif payload.get("brief") is True:
lines.append(
f"- brief_prompt_command: `{payload.get('brief_prompt_command')}`"
)
else:
lines.extend(
[
f"- expanded_prompt_command: `{payload.get('expanded_prompt_command')}`",
f"- compact_prompt_command: `{payload.get('compact_prompt_command')}`",
f"- brief_prompt_command: `{payload.get('brief_prompt_command')}`",
f"- thin_prompt_command: `{payload.get('thin_prompt_command')}`",
]
)
lines.extend(
[
f"- agent_scopes: `{payload.get('agent_scopes')}`",
f"- expanded_prompt_command: `{payload.get('expanded_prompt_command')}`",
f"- compact_prompt_command: `{payload.get('compact_prompt_command')}`",
f"- brief_prompt_command: `{payload.get('brief_prompt_command')}`",
f"- thin_prompt_command: `{payload.get('thin_prompt_command')}`",
"- pr_review_pre_quota_command: "
f"`{payload.get('pr_review_pre_quota_command')}`",
f"- quota_guard_command: `{payload.get('quota_guard_command')}`",
Expand Down
26 changes: 26 additions & 0 deletions tests/control_plane/test_heartbeat_prompt_support.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,32 @@ def test_public_facade_still_builds_and_renders_prompts() -> None:
assert render_heartbeat_prompt_markdown(payload)


def test_thin_markdown_diagnostics_only_show_the_selected_prompt_command() -> None:
payload = build_heartbeat_prompt(goal_id="loopx-meta", thin=True)
rendered = render_heartbeat_prompt_markdown(payload)

assert payload["task_body"] in rendered
assert "- thin_prompt_command:" in rendered
assert "- expanded_prompt_command:" not in rendered
assert "- compact_prompt_command:" not in rendered
assert "- brief_prompt_command:" not in rendered


def test_brief_diagnostics_keep_only_the_selected_prompt_command() -> None:
payload = build_heartbeat_prompt(goal_id="loopx-meta", brief=True)
rendered = render_heartbeat_prompt_markdown(payload)

assert payload["brief_prompt_command"]
assert "compact_prompt_command" not in payload
assert "expanded_prompt_command" not in payload
assert "thin_prompt_command" not in payload
assert "heartbeat-prompt --compact" in payload["task_body"]
assert "- brief_prompt_command:" in rendered
assert "- expanded_prompt_command:" not in rendered
assert "- compact_prompt_command:" not in rendered
assert "- thin_prompt_command:" not in rendered


@pytest.mark.parametrize(
("mode", "base_budget"),
[("full", 12000), ("compact", 6500), ("brief", 4300), ("thin", 3000)],
Expand Down
Loading