diff --git a/codex-rs/core/plan_mode_prompt.md b/codex-rs/core/plan_mode_prompt.md
index 31b3054efc..5689f3a178 100644
--- a/codex-rs/core/plan_mode_prompt.md
+++ b/codex-rs/core/plan_mode_prompt.md
@@ -1,20 +1,5 @@
## Plan Mode
-You are now in **Plan Mode**. Your job is to understand the user's request, explore the codebase and design an implementation approach. You should get user sign-off using the RequestUserInput *before* making large or risky changes.
----
-## Plan artifact (required)
-In Plan Mode, you must create and maintain a living plan file:
-- Create a Markdown file at: **`$CODEX_HOME/plans/PLAN.md`**
-- Make it **readable and skimmable**, broken into **digestible sections**
-- Use **checkbox task lists** (`- [ ]`, `- [x]`) so both you and the user can track progress
-- Treat `PLAN.md` as the **single source of truth** for the approach and current status
-**Collaboration note:** The user may edit `PLAN.md` too. If it changes in ways you didn’t do directly, **don’t be alarmed**—reconcile with the new content and continue.
-
-## Editing rule (required)
-As you work, keep `PLAN.md` up to date:
-- Update the plan **as soon as new information changes the approach**
-- Mark completed steps by checking boxes (`[x]`)
-- Add/remove steps when scope changes
-- Edit using **`apply_patch`** (preferred) so changes are minimal, reviewable, and don’t clobber user edits
+You are now in **Plan Mode**. Your job is to understand the user's request, explore the codebase and design an implementation approach.
## What happens in Plan Mode
In Plan Mode, you will:
@@ -29,8 +14,54 @@ In Plan Mode, you will:
- Sequencing
- Testing/verification
- **Write the plan into `PLAN.md`**, then present a concise summary to the user for approval
+- The final output should always start with `***Here is the plan***` and then following the ouput format below exactly.
+
+
+## Plan ouput format (required) — MUST MATCH *exactly*
+Use this exact Markdown structure so it can be parsed and updated reliably:
+
+```markdown
+# Plan:
+
+## Metadata
+- plan_id:
+- thread_id:
+- status: Draft | Questions | Final | Executing | Done
+- created_at: YYYY-MM-DDTHH:MM:SSZ
+- updated_at: YYYY-MM-DDTHH:MM:SSZ
+
+## Goal
+<1-3 sentences>
+
+## Constraints
+-
+
+## Strategy
+-
+
+## Steps
+- [ ] Step 1 —
+- [ ] Step 2 —
+
+## Open Questions
+1.
+2.
+
+## Decisions / Answers
+- Q1:
+- Q2:
+
+## Risks
+-
+
+## Notes
+-
+```
+
+## Editing rule (required)
+As you work, keep `PLAN.md` up to date:
+- Update the plan **as soon as new information changes the approach**
+- Mark completed steps by checking boxes (`[x]`)
+- Add/remove steps when scope changes
+- Edit using **`apply_patch`** (preferred) so changes are minimal, reviewable, and don’t clobber user edits
-## Using `RequestUserInput` in Plan Mode
-Use `RequestUserInput` only when you are genuinely blocked on a decision that materially changes the plan (requirements, trade-offs, rollout/risk posture). Prefer **1 question** by default and the max number of RequestUserInput tool call should be **3**.
-Do **not** use `RequestUserInput` to ask “is my plan ready?” or “should I proceed?”
-Plan approval happens by presenting `PLAN.md` (or a brief summary of it) and asking for explicit sign-off.
diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs
index 5f4ef81436..e191bf7de8 100644
--- a/codex-rs/core/src/codex.rs
+++ b/codex-rs/core/src/codex.rs
@@ -547,10 +547,12 @@ impl Session {
web_search_mode: per_turn_config.web_search_mode,
});
- let developer_instructions = if matches!(
+ let is_plan_mode = matches!(
session_configuration.collaboration_mode,
CollaborationMode::Plan(_)
- ) {
+ );
+
+ let developer_instructions = if is_plan_mode {
match session_configuration.developer_instructions.as_deref() {
Some(base) => Some(format!("{base}\n\n{PLAN_MODE_PROMPT}")),
None => Some(PLAN_MODE_PROMPT.to_string()),
@@ -559,12 +561,18 @@ impl Session {
session_configuration.developer_instructions.clone()
};
+ let base_instructions = if is_plan_mode {
+ Some(PLAN_MODE_PROMPT.to_string())
+ } else {
+ session_configuration.base_instructions.clone()
+ };
+
TurnContext {
sub_id,
client,
cwd: session_configuration.cwd.clone(),
developer_instructions,
- base_instructions: session_configuration.base_instructions.clone(),
+ base_instructions,
compact_prompt: session_configuration.compact_prompt.clone(),
user_instructions: session_configuration.user_instructions.clone(),
approval_policy: session_configuration.approval_policy.value(),