feat(cli): show raw reasoning content

This commit is contained in:
aibrahim-oai
2025-07-13 23:39:56 -07:00
parent c46bb67d77
commit caab634c57
9 changed files with 85 additions and 5 deletions
+19 -1
View File
@@ -15,6 +15,7 @@ use codex_core::protocol::McpToolCallBeginEvent;
use codex_core::protocol::McpToolCallEndEvent;
use codex_core::protocol::PatchApplyBeginEvent;
use codex_core::protocol::PatchApplyEndEvent;
use codex_core::protocol::AgentReasoningContentEvent;
use codex_core::protocol::SessionConfiguredEvent;
use codex_core::protocol::TokenUsage;
use owo_colors::OwoColorize;
@@ -50,10 +51,15 @@ pub(crate) struct EventProcessor {
/// Whether to include `AgentReasoning` events in the output.
show_agent_reasoning: bool,
show_agent_reasoning_content: bool,
}
impl EventProcessor {
pub(crate) fn create_with_ansi(with_ansi: bool, show_agent_reasoning: bool) -> Self {
pub(crate) fn create_with_ansi(
with_ansi: bool,
show_agent_reasoning: bool,
show_agent_reasoning_content: bool,
) -> Self {
let call_id_to_command = HashMap::new();
let call_id_to_patch = HashMap::new();
let call_id_to_tool_call = HashMap::new();
@@ -71,6 +77,7 @@ impl EventProcessor {
cyan: Style::new().cyan(),
call_id_to_tool_call,
show_agent_reasoning,
show_agent_reasoning_content,
}
} else {
Self {
@@ -85,6 +92,7 @@ impl EventProcessor {
cyan: Style::new(),
call_id_to_tool_call,
show_agent_reasoning,
show_agent_reasoning_content,
}
}
}
@@ -449,6 +457,16 @@ impl EventProcessor {
);
}
}
EventMsg::AgentReasoningContent(agent_reasoning_event) => {
if self.show_agent_reasoning && self.show_agent_reasoning_content {
ts_println!(
self,
"{}\n{}",
"thinking".style(self.italic).style(self.magenta),
agent_reasoning_event.text
);
}
}
EventMsg::SessionConfigured(session_configured_event) => {
let SessionConfiguredEvent {
session_id,
+5 -2
View File
@@ -115,8 +115,11 @@ pub async fn run_main(cli: Cli, codex_linux_sandbox_exe: Option<PathBuf>) -> any
};
let config = Config::load_with_cli_overrides(cli_kv_overrides, overrides)?;
let mut event_processor =
EventProcessor::create_with_ansi(stdout_with_ansi, !config.hide_agent_reasoning);
let mut event_processor = EventProcessor::create_with_ansi(
stdout_with_ansi,
!config.hide_agent_reasoning,
config.show_reasoning_content,
);
// Print the effective configuration and prompt so users can see what Codex
// is using.
event_processor.print_config_summary(&config, &prompt);