From 290ee318d140650d906f8c7793df27201530741b Mon Sep 17 00:00:00 2001 From: Roy Han Date: Fri, 20 Mar 2026 16:53:51 -0700 Subject: [PATCH] remove redundant stamping --- codex-rs/core/src/codex.rs | 46 +++---------------------------- codex-rs/core/src/hook_runtime.rs | 3 -- codex-rs/core/src/tasks/mod.rs | 8 +----- 3 files changed, 5 insertions(+), 52 deletions(-) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index 7ebfcaba69..ca66dee92f 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -3819,40 +3819,7 @@ impl Session { turn_context: &TurnContext, input: &[UserInput], response_item: ResponseItem, - user_message_type: Option, ) { - let user_message_type = if self.enabled(Feature::ItemMetadata) { - user_message_type - } else { - None - }; - - let response_item = match (response_item, user_message_type.clone()) { - ( - ResponseItem::Message { - id, - role, - content, - metadata, - end_turn, - phase, - }, - Some(kind), - ) if role == "user" => { - let mut metadata = metadata.unwrap_or_default(); - metadata.user_message_type = Some(kind); - ResponseItem::Message { - id, - role, - content, - metadata: Some(metadata), - end_turn, - phase, - } - } - (response_item, _) => response_item, - }; - // Persist the user message to history, but emit the turn item from `UserInput` so // UI-only `text_elements` are preserved. `ResponseItem::Message` does not carry // those spans, and `record_response_item_and_emit_turn_item` would drop them. @@ -5697,13 +5664,8 @@ pub(crate) async fn run_turn( stamp_user_message_type_on_input_item(&mut initial_input_for_turn, UserMessageType::Prompt); } let response_item: ResponseItem = initial_input_for_turn.clone().into(); - sess.record_user_prompt_and_emit_turn_item( - turn_context.as_ref(), - &input, - response_item, - Some(UserMessageType::Prompt), - ) - .await; + sess.record_user_prompt_and_emit_turn_item(turn_context.as_ref(), &input, response_item) + .await; record_additional_contexts(&sess, &turn_context, additional_contexts).await; // Track the previous-turn baseline from the regular user-turn path only so // standalone tasks (compact/shell/review/undo) cannot suppress future @@ -5775,8 +5737,8 @@ pub(crate) async fn run_turn( } let has_accepted_pending_input = !accepted_pending_input.is_empty(); - for (pending_input, user_message_type) in accepted_pending_input { - record_pending_input(&sess, &turn_context, pending_input, user_message_type).await; + for (pending_input, _user_message_type) in accepted_pending_input { + record_pending_input(&sess, &turn_context, pending_input).await; } record_additional_contexts(&sess, &turn_context, blocked_pending_input_contexts).await; diff --git a/codex-rs/core/src/hook_runtime.rs b/codex-rs/core/src/hook_runtime.rs index 434972ba5d..26b49facc3 100644 --- a/codex-rs/core/src/hook_runtime.rs +++ b/codex-rs/core/src/hook_runtime.rs @@ -8,7 +8,6 @@ use codex_protocol::items::TurnItem; use codex_protocol::models::DeveloperInstructions; use codex_protocol::models::ResponseInputItem; use codex_protocol::models::ResponseItem; -use codex_protocol::models::UserMessageType; use codex_protocol::protocol::AskForApproval; use codex_protocol::protocol::EventMsg; use codex_protocol::protocol::HookCompletedEvent; @@ -165,7 +164,6 @@ pub(crate) async fn record_pending_input( sess: &Arc, turn_context: &Arc, pending_input: PendingInputRecord, - user_message_type: Option, ) { match pending_input { PendingInputRecord::UserMessage { @@ -177,7 +175,6 @@ pub(crate) async fn record_pending_input( turn_context.as_ref(), content.as_slice(), response_item, - user_message_type, ) .await; record_additional_contexts(sess, turn_context, additional_contexts).await; diff --git a/codex-rs/core/src/tasks/mod.rs b/codex-rs/core/src/tasks/mod.rs index 357aceae27..a1f53d0b49 100644 --- a/codex-rs/core/src/tasks/mod.rs +++ b/codex-rs/core/src/tasks/mod.rs @@ -265,13 +265,7 @@ impl Session { for pending_input_item in pending_input { match inspect_pending_input(self, &turn_context, pending_input_item.input).await { PendingInputHookDisposition::Accepted(pending_input) => { - record_pending_input( - self, - &turn_context, - *pending_input, - pending_input_item.user_message_type, - ) - .await; + record_pending_input(self, &turn_context, *pending_input).await; } PendingInputHookDisposition::Blocked { additional_contexts,