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
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ fields can rerun the advertised command or pass
`--include-command-pack-detail`. Both modes must produce the same host-action
projection before a compact default is promoted.

If the recommendation repeats the planning prompt, the default packet supplies
`recommended_next_step.plan_prompt_ref` as a JSON Pointer to the complete
prompt in that same packet. Follow it without a second command. The ordered
planning step and the explicit detail view retain their inline text.

`start-goal --project <path>` keeps that exact project route. In particular, a
fresh linked worktree must not silently inherit a goal registered by another
worktree that shares its Git common directory. The lower-level
Expand Down
13 changes: 11 additions & 2 deletions loopx/bootstrap_command_pack.py
Original file line number Diff line number Diff line change
Expand Up @@ -1484,6 +1484,7 @@ def build_start_goal_guided_packet(
)
commands = command_pack.get("commands")
commands = commands if isinstance(commands, dict) else {}
plan_prompt = commands.get("goal_start_plan_prompt")
activation = command_pack.get("host_loop_activation")
activation = activation if isinstance(activation, dict) else {}
identity_selection_gate = activation.get("identity_selection_gate")
Expand Down Expand Up @@ -1611,7 +1612,7 @@ def rerun_start_goal(selected_agent_id: str) -> str:
*fine_mode_steps,
*todo_authoring_steps(
existing_runnable_frontier=guided_frontier,
plan_prompt=commands.get("goal_start_plan_prompt"),
plan_prompt=plan_prompt,
fine_grained=fine_grained,
cli_bin=cli_bin,
runtime_root=command_pack.get("command_runtime_root"),
Expand Down Expand Up @@ -1772,6 +1773,14 @@ def rerun_start_goal(selected_agent_id: str) -> str:
if isinstance(orphaned_gate, dict):
guided_transaction.update(guided_fence(orphaned_gate))
guided_transaction.pop("identity_selection_gate", None)
recommendation = command_pack.get("recommended_next_step")
if (not include_command_pack_detail and isinstance(recommendation, dict)
and isinstance(plan_prompt, str) and plan_prompt
and recommendation.get("plan_prompt") == plan_prompt):
# The same packet already carries the complete prompt in its commands.
recommendation = dict(recommendation)
del recommendation["plan_prompt"]
recommendation["plan_prompt_ref"] = "#/command_pack/commands/goal_start_plan_prompt"
payload = {
"ok": True,
"schema_version": GUIDED_START_SCHEMA_VERSION,
Expand All @@ -1783,7 +1792,7 @@ def rerun_start_goal(selected_agent_id: str) -> str:
"host_surface": command_pack.get("host_surface"),
"goal_text": command_pack.get("goal_text"),
"project_connection": command_pack.get("project_connection"),
"recommended_next_step": command_pack.get("recommended_next_step"),
"recommended_next_step": recommendation,
"guided_transaction": guided_transaction,
"command_pack": selected_command_pack,
"command_pack_detail_included": include_command_pack_detail,
Expand Down
22 changes: 18 additions & 4 deletions tests/control_plane/test_start_goal_compact_projection.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@ def _build(project: Path, *, include_detail: bool) -> dict[str, Any]:
def _host_shadow_document(payload: dict[str, Any]) -> dict[str, Any]:
command_pack = payload["command_pack"]
transaction = payload["guided_transaction"]
recommendation = dict(payload["recommended_next_step"])
if "plan_prompt_ref" in recommendation:
assert "plan_prompt" not in recommendation
recommendation["plan_prompt"] = _resolve_pointer(payload, recommendation.pop("plan_prompt_ref"))
return {
"schema_version": payload["schema_version"],
"project": payload["project"],
Expand All @@ -110,7 +114,7 @@ def _host_shadow_document(payload: dict[str, Any]) -> dict[str, Any]:
"agent_id": payload["agent_id"],
"host_surface": payload["host_surface"],
"goal_text": payload["goal_text"],
"recommended_next_step": payload["recommended_next_step"],
"recommended_next_step": recommendation,
"ordered_steps": transaction["ordered_steps"],
"idempotency_policy": transaction["idempotency_policy"],
"preserve_todos_policy": transaction["preserve_todos_policy"],
Expand Down Expand Up @@ -551,14 +555,24 @@ def test_invalid_idle_timeout_remediation_reuses_typed_runtime_message(


def test_default_projection_preserves_host_actions_and_json_anchors(
tmp_path: Path,
tmp_path: Path, monkeypatch: pytest.MonkeyPatch,
) -> None:
monkeypatch.delenv("CODEX_THREAD_ID", raising=False)
project = _write_connected_project(tmp_path)
compact = _build(project, include_detail=False)
detailed = _build(project, include_detail=True)
code, compact = _invoke_start_goal_for_host(project, "codex-app")
detail_code, detailed = _invoke_start_goal_for_host(project, "codex-app", include_detail=True)
assert code == detail_code == 0

assert set(compact) == set(detailed)
assert _host_shadow_document(compact) == _host_shadow_document(detailed)
recommendation = compact["recommended_next_step"]
assert "plan_prompt" not in recommendation
assert recommendation["plan_prompt_ref"] == "#/command_pack/commands/goal_start_plan_prompt"
assert _resolve_pointer(compact, recommendation["plan_prompt_ref"]) == (
detailed["recommended_next_step"]["plan_prompt"]
)
assert "plan_prompt_ref" not in detailed["recommended_next_step"]
assert compact["message"] == detailed["message"]
assert compact["command_pack_detail_included"] is False
assert detailed["command_pack_detail_included"] is True
assert compact["guided_transaction"]["ordered_steps"][-1]["id"] == (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lark_private_conversations.py
Original file line number Diff line number Diff line change
Expand Up @@ -2813,7 +2813,7 @@ def test_app_messages_and_answers_reach_the_original_chat_once_without_new_execu
runtime.close()


def test_app_projection_discovers_a_restored_transcript_with_the_same_size_and_mtime(ordinary):
def test_app_projection_discovers_a_restored_transcript_with_the_same_size_and_mtime(ordinary): # noqa: F811
import os

store, runtime, provider, transport, original, turns, before = _app_projection_journey(ordinary)
Expand Down
Loading