diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 710cb832e9..c282a94b91 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -1005,6 +1005,7 @@ async fn run_task(sess: Arc, sub_id: String, input: Vec) { id, summary, encrypted_content, + content, }, None, ) => { @@ -1012,6 +1013,7 @@ async fn run_task(sess: Arc, sub_id: String, input: Vec) { id: id.clone(), summary: summary.clone(), encrypted_content: encrypted_content.clone(), + content: content.clone(), }); } _ => { @@ -1272,12 +1274,12 @@ async fn handle_response_item( id: _, summary, content, + encrypted_content: _, } => { for item in summary { let text = match item { ReasoningItemReasoningSummary::SummaryText { text } => text, }; - info!("Agent reasoning: {text}"); let event = Event { id: sub_id.to_string(), msg: EventMsg::AgentReasoning(AgentReasoningEvent { text }), @@ -1288,7 +1290,6 @@ async fn handle_response_item( let text = match item { ReasoningItemContent::ReasoningText { text } => text, }; - info!("Agent reasoning content: {text}"); let event = Event { id: sub_id.to_string(), msg: EventMsg::AgentReasoningContent(AgentReasoningContentEvent { text }), diff --git a/codex-rs/core/src/protocol.rs b/codex-rs/core/src/protocol.rs index 2111aff74f..36152b4cb8 100644 --- a/codex-rs/core/src/protocol.rs +++ b/codex-rs/core/src/protocol.rs @@ -308,7 +308,7 @@ pub enum EventMsg { /// Agent reasoning delta event from agent. AgentReasoningDelta(AgentReasoningDeltaEvent), - + /// Raw chain-of-thought from agent. AgentReasoningContent(AgentReasoningContentEvent), @@ -417,6 +417,7 @@ pub struct AgentReasoningContentEvent { pub text: String, } +#[derive(Debug, Clone, Deserialize, Serialize)] pub struct AgentReasoningDeltaEvent { pub delta: String, } diff --git a/codex-rs/exec/src/event_processor_with_human_output.rs b/codex-rs/exec/src/event_processor_with_human_output.rs index 54604d538b..ec7bd8b5c4 100644 --- a/codex-rs/exec/src/event_processor_with_human_output.rs +++ b/codex-rs/exec/src/event_processor_with_human_output.rs @@ -4,6 +4,7 @@ use codex_core::config::Config; use codex_core::plan_tool::UpdatePlanArgs; use codex_core::protocol::AgentMessageDeltaEvent; use codex_core::protocol::AgentMessageEvent; +use codex_core::protocol::AgentReasoningContentEvent; use codex_core::protocol::AgentReasoningDeltaEvent; use codex_core::protocol::BackgroundEventEvent; use codex_core::protocol::ErrorEvent; @@ -204,6 +205,11 @@ impl EventProcessor for EventProcessorWithHumanOutput { #[allow(clippy::expect_used)] std::io::stdout().flush().expect("could not flush stdout"); } + EventMsg::AgentReasoningContent(AgentReasoningContentEvent { text }) => { + print!("{text}"); + #[allow(clippy::expect_used)] + std::io::stdout().flush().expect("could not flush stdout"); + } EventMsg::AgentMessage(AgentMessageEvent { message }) => { // if answer_started is false, this means we haven't received any // delta. Thus, we need to print the message as a new answer. diff --git a/codex-rs/tui/src/chatwidget.rs b/codex-rs/tui/src/chatwidget.rs index f81e35d375..c4c2de7761 100644 --- a/codex-rs/tui/src/chatwidget.rs +++ b/codex-rs/tui/src/chatwidget.rs @@ -275,12 +275,8 @@ impl ChatWidget<'_> { self.request_redraw(); } EventMsg::AgentReasoningContent(AgentReasoningContentEvent { text }) => { - if !self.config.hide_agent_reasoning && self.config.show_reasoning_content { - let text = format!("Full Reasoning Content: {text}"); - self.conversation_history - .add_agent_reasoning(&self.config, text); - self.request_redraw(); - } + self.add_to_history(HistoryCell::new_agent_reasoning(&self.config, text)); + self.request_redraw(); } EventMsg::TaskStarted => { self.bottom_pane.clear_ctrl_c_quit_hint();