From 5fae58d1ed78171e0921e79a3a5bfc6883683b2d Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Tue, 7 Jul 2026 20:41:44 -0700 Subject: [PATCH 1/2] chore(protocol): use UUIDv7 for generated item IDs --- codex-rs/protocol/src/items.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/codex-rs/protocol/src/items.rs b/codex-rs/protocol/src/items.rs index 2c9d073f0dce..6a24ee267171 100644 --- a/codex-rs/protocol/src/items.rs +++ b/codex-rs/protocol/src/items.rs @@ -381,7 +381,7 @@ pub struct ContextCompactionItem { impl ContextCompactionItem { pub fn new() -> Self { Self { - id: uuid::Uuid::new_v4().to_string(), + id: uuid::Uuid::now_v7().to_string(), } } } @@ -395,7 +395,7 @@ impl Default for ContextCompactionItem { impl UserMessageItem { pub fn new(content: &[UserInput]) -> Self { Self { - id: uuid::Uuid::new_v4().to_string(), + id: uuid::Uuid::now_v7().to_string(), client_id: None, content: content.to_vec(), } @@ -499,7 +499,7 @@ impl HookPromptItem { Self { id: id .cloned() - .unwrap_or_else(|| uuid::Uuid::new_v4().to_string()), + .unwrap_or_else(|| uuid::Uuid::now_v7().to_string()), fragments, } } @@ -529,7 +529,7 @@ pub fn build_hook_prompt_message(fragments: &[HookPromptFragment]) -> Option Option Self { Self { - id: uuid::Uuid::new_v4().to_string(), + id: uuid::Uuid::now_v7().to_string(), content: content.to_vec(), phase: None, memory_citation: None, From 75686a9b040f0c04a6dafffe9336f26425d6942f Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Wed, 8 Jul 2026 11:20:41 -0700 Subject: [PATCH 2/2] update --- codex-rs/protocol/src/items.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/codex-rs/protocol/src/items.rs b/codex-rs/protocol/src/items.rs index 6a24ee267171..c90d6e7d87c8 100644 --- a/codex-rs/protocol/src/items.rs +++ b/codex-rs/protocol/src/items.rs @@ -378,11 +378,13 @@ pub struct ContextCompactionItem { pub id: String, } +fn new_item_id() -> String { + uuid::Uuid::now_v7().to_string() +} + impl ContextCompactionItem { pub fn new() -> Self { - Self { - id: uuid::Uuid::now_v7().to_string(), - } + Self { id: new_item_id() } } } @@ -395,7 +397,7 @@ impl Default for ContextCompactionItem { impl UserMessageItem { pub fn new(content: &[UserInput]) -> Self { Self { - id: uuid::Uuid::now_v7().to_string(), + id: new_item_id(), client_id: None, content: content.to_vec(), } @@ -497,9 +499,7 @@ fn trim_trailing_default_image_details( impl HookPromptItem { pub fn from_fragments(id: Option<&String>, fragments: Vec) -> Self { Self { - id: id - .cloned() - .unwrap_or_else(|| uuid::Uuid::now_v7().to_string()), + id: id.cloned().unwrap_or_else(new_item_id), fragments, } } @@ -529,7 +529,7 @@ pub fn build_hook_prompt_message(fragments: &[HookPromptFragment]) -> Option Option Self { Self { - id: uuid::Uuid::now_v7().to_string(), + id: new_item_id(), content: content.to_vec(), phase: None, memory_citation: None,