Skip to content

Commit ef72083

Browse files
authored
feat: show Config overview at start of exec (#1073)
Now the `exec` output starts with something like: ``` -------- workdir: /Users/mbolin/code/codex/codex-rs model: o3 provider: openai approval: Never sandbox: SandboxPolicy { permissions: [DiskFullReadAccess, DiskWritePlatformUserTempFolder, DiskWritePlatformGlobalTempFolder, DiskWriteCwd, DiskWriteFolder { folder: "/Users/mbolin/.pyenv/shims" }] } -------- ``` which makes it easier to reason about when looking at logs.
1 parent 5746561 commit ef72083

File tree

2 files changed

+43
-12
lines changed

2 files changed

+43
-12
lines changed

codex-rs/exec/src/event_processor.rs

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use chrono::Utc;
22
use codex_common::elapsed::format_elapsed;
3+
use codex_core::config::Config;
34
use codex_core::protocol::AgentMessageEvent;
45
use codex_core::protocol::BackgroundEventEvent;
56
use codex_core::protocol::ErrorEvent;
@@ -13,7 +14,6 @@ use codex_core::protocol::McpToolCallEndEvent;
1314
use codex_core::protocol::PatchApplyBeginEvent;
1415
use codex_core::protocol::PatchApplyEndEvent;
1516
use codex_core::protocol::SessionConfiguredEvent;
16-
use codex_core::protocol::TaskCompleteEvent;
1717
use owo_colors::OwoColorize;
1818
use owo_colors::Style;
1919
use shlex::try_join;
@@ -103,9 +103,36 @@ macro_rules! ts_println {
103103
}};
104104
}
105105

106+
/// Print a concise summary of the effective configuration that will be used
107+
/// for the session. This mirrors the information shown in the TUI welcome
108+
/// screen.
109+
pub(crate) fn print_config_summary(config: &Config, with_ansi: bool) {
110+
let bold = if with_ansi {
111+
Style::new().bold()
112+
} else {
113+
Style::new()
114+
};
115+
116+
ts_println!("OpenAI Codex (research preview)\n--------");
117+
118+
let entries = vec![
119+
("workdir", config.cwd.display().to_string()),
120+
("model", config.model.clone()),
121+
("provider", config.model_provider_id.clone()),
122+
("approval", format!("{:?}", config.approval_policy)),
123+
("sandbox", format!("{:?}", config.sandbox_policy)),
124+
];
125+
126+
for (key, value) in entries {
127+
println!("{} {}", format!("{key}: ").style(bold), value);
128+
}
129+
130+
println!("--------\n");
131+
}
132+
106133
impl EventProcessor {
107134
pub(crate) fn process_event(&mut self, event: Event) {
108-
let Event { id, msg } = event;
135+
let Event { id: _, msg } = event;
109136
match msg {
110137
EventMsg::Error(ErrorEvent { message }) => {
111138
let prefix = "ERROR:".style(self.red);
@@ -114,15 +141,8 @@ impl EventProcessor {
114141
EventMsg::BackgroundEvent(BackgroundEventEvent { message }) => {
115142
ts_println!("{}", message.style(self.dimmed));
116143
}
117-
EventMsg::TaskStarted => {
118-
let msg = format!("Task started: {id}");
119-
ts_println!("{}", msg.style(self.dimmed));
120-
}
121-
EventMsg::TaskComplete(TaskCompleteEvent {
122-
last_agent_message: _,
123-
}) => {
124-
let msg = format!("Task complete: {id}");
125-
ts_println!("{}", msg.style(self.bold));
144+
EventMsg::TaskStarted | EventMsg::TaskComplete(_) => {
145+
// Ignore.
126146
}
127147
EventMsg::AgentMessage(AgentMessageEvent { message }) => {
128148
let prefix = "Agent message:".style(self.bold);
@@ -385,7 +405,15 @@ impl EventProcessor {
385405
history_log_id: _,
386406
history_entry_count: _,
387407
} = session_configured_event;
388-
println!("session {session_id} with model {model}");
408+
409+
ts_println!(
410+
"{} {}",
411+
"codex session".style(self.magenta).style(self.bold),
412+
session_id.to_string().style(self.dimmed)
413+
);
414+
415+
ts_println!("model: {}", model);
416+
println!();
389417
}
390418
EventMsg::GetHistoryEntryResponse(_) => {
391419
// Currently ignored in exec output.

codex-rs/exec/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ use codex_core::protocol::SandboxPolicy;
1818
use codex_core::protocol::TaskCompleteEvent;
1919
use codex_core::util::is_inside_git_repo;
2020
use event_processor::EventProcessor;
21+
use event_processor::print_config_summary;
2122
use tracing::debug;
2223
use tracing::error;
2324
use tracing::info;
@@ -70,6 +71,8 @@ pub async fn run_main(cli: Cli) -> anyhow::Result<()> {
7071
model_provider: None,
7172
};
7273
let config = Config::load_with_overrides(overrides)?;
74+
// Print the effective configuration so users can see what Codex is using.
75+
print_config_summary(&config, stdout_with_ansi);
7376

7477
if !skip_git_repo_check && !is_inside_git_repo(&config) {
7578
eprintln!("Not inside a Git repo and --skip-git-repo-check was not specified.");

0 commit comments

Comments
 (0)