Skip to content

Commit 594248f

Browse files
[exec] add include-plan-tool flag and print it nicely (#3461)
### Summary Sometimes in exec runs, we want to allow the model to use the `update_plan` tool, but that's not easily configurable. This change adds a feature flag for this, and formats the output so it's human-readable ## Test Plan <img width="1280" height="354" alt="Screenshot 2025-09-11 at 12 39 44 AM" src="https://github.com/user-attachments/assets/72e11070-fb98-47f5-a784-5123ca7333d9" />
1 parent 8227a5b commit 594248f

File tree

3 files changed

+37
-3
lines changed

3 files changed

+37
-3
lines changed

codex-rs/exec/src/cli.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ pub struct Cli {
6767
#[arg(long = "json", default_value_t = false)]
6868
pub json: bool,
6969

70+
/// Whether to include the plan tool in the conversation.
71+
#[arg(long = "include-plan-tool", default_value_t = false)]
72+
pub include_plan_tool: bool,
73+
7074
/// Specifies file where the last message from the agent should be written.
7175
#[arg(long = "output-last-message")]
7276
pub last_message_file: Option<PathBuf>,

codex-rs/exec/src/event_processor_with_human_output.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -539,8 +539,37 @@ impl EventProcessor for EventProcessorWithHumanOutput {
539539
}
540540
EventMsg::PlanUpdate(plan_update_event) => {
541541
let UpdatePlanArgs { explanation, plan } = plan_update_event;
542-
ts_println!(self, "explanation: {explanation:?}");
543-
ts_println!(self, "plan: {plan:?}");
542+
543+
// Header
544+
ts_println!(self, "{}", "Plan update".style(self.magenta));
545+
546+
// Optional explanation
547+
if let Some(explanation) = explanation
548+
&& !explanation.trim().is_empty()
549+
{
550+
ts_println!(self, "{}", explanation.style(self.italic));
551+
}
552+
553+
// Pretty-print the plan items with simple status markers.
554+
for item in plan {
555+
use codex_core::plan_tool::StepStatus;
556+
match item.status {
557+
StepStatus::Completed => {
558+
ts_println!(self, " {} {}", "✓".style(self.green), item.step);
559+
}
560+
StepStatus::InProgress => {
561+
ts_println!(self, " {} {}", "→".style(self.cyan), item.step);
562+
}
563+
StepStatus::Pending => {
564+
ts_println!(
565+
self,
566+
" {} {}",
567+
"•".style(self.dimmed),
568+
item.step.style(self.dimmed)
569+
);
570+
}
571+
}
572+
}
544573
}
545574
EventMsg::GetHistoryEntryResponse(_) => {
546575
// Currently ignored in exec output.

codex-rs/exec/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
5353
sandbox_mode: sandbox_mode_cli_arg,
5454
prompt,
5555
output_schema: output_schema_path,
56+
include_plan_tool,
5657
config_overrides,
5758
} = cli;
5859

@@ -161,7 +162,7 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
161162
model_provider,
162163
codex_linux_sandbox_exe,
163164
base_instructions: None,
164-
include_plan_tool: None,
165+
include_plan_tool: Some(include_plan_tool),
165166
include_apply_patch_tool: None,
166167
include_view_image_tool: None,
167168
show_raw_agent_reasoning: oss.then_some(true),

0 commit comments

Comments
 (0)