From a32597fd74016b98163c001a3a3dc5d69587689c Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Fri, 13 Nov 2026 02:33:03 +0800 Subject: [PATCH 1/2] test(lark): mark the imported transcript fixture for Ruff Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- tests/test_lark_private_conversations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_lark_private_conversations.py b/tests/test_lark_private_conversations.py index b3e1d8cc59..0e35a7c3b1 100644 --- a/tests/test_lark_private_conversations.py +++ b/tests/test_lark_private_conversations.py @@ -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) From d1a6c5b906803f3f0a2601882c717bf0a6af4fe1 Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Fri, 13 Nov 2026 04:07:18 +0800 Subject: [PATCH 2/2] Reference the existing planning prompt in guided start Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- .../codex-app-host-command-registry-v0.md | 5 +++++ loopx/bootstrap_command_pack.py | 13 +++++++++-- .../test_start_goal_compact_projection.py | 22 +++++++++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/docs/reference/protocols/codex-app-host-command-registry-v0.md b/docs/reference/protocols/codex-app-host-command-registry-v0.md index f95f714c58..684e3b9ff6 100644 --- a/docs/reference/protocols/codex-app-host-command-registry-v0.md +++ b/docs/reference/protocols/codex-app-host-command-registry-v0.md @@ -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 ` 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 diff --git a/loopx/bootstrap_command_pack.py b/loopx/bootstrap_command_pack.py index 3cf4437cab..0d580cb55b 100644 --- a/loopx/bootstrap_command_pack.py +++ b/loopx/bootstrap_command_pack.py @@ -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") @@ -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"), @@ -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, @@ -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, diff --git a/tests/control_plane/test_start_goal_compact_projection.py b/tests/control_plane/test_start_goal_compact_projection.py index 8c05b8adf4..285ba8e4e5 100644 --- a/tests/control_plane/test_start_goal_compact_projection.py +++ b/tests/control_plane/test_start_goal_compact_projection.py @@ -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"], @@ -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"], @@ -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"] == (