From bbd91ab14ebbe3966f9e9ce64d6ce5a378990d6c Mon Sep 17 00:00:00 2001 From: Michael Zeng Date: Mon, 6 Jul 2026 15:35:17 -0700 Subject: [PATCH] [thread-store] separate history materialization --- codex-rs/thread-store/src/local/live_writer.rs | 11 +++++++++-- .../thread-store/src/local/update_thread_metadata.rs | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/codex-rs/thread-store/src/local/live_writer.rs b/codex-rs/thread-store/src/local/live_writer.rs index 6bacecd5a0..2aebe99080 100644 --- a/codex-rs/thread-store/src/local/live_writer.rs +++ b/codex-rs/thread-store/src/local/live_writer.rs @@ -168,6 +168,14 @@ pub(super) async fn append_items( pub(super) async fn persist_thread( store: &LocalThreadStore, thread_id: ThreadId, +) -> ThreadStoreResult<()> { + persist_history(store, thread_id).await?; + store.flush_pending_metadata_update(thread_id).await +} + +pub(super) async fn persist_history( + store: &LocalThreadStore, + thread_id: ThreadId, ) -> ThreadStoreResult<()> { store .live_recorder(thread_id) @@ -175,8 +183,7 @@ pub(super) async fn persist_thread( .persist() .await .map_err(thread_store_io_error)?; - sync_materialized_rollout_path(store, thread_id).await?; - store.flush_pending_metadata_update(thread_id).await + sync_materialized_rollout_path(store, thread_id).await } pub(super) async fn flush_thread( diff --git a/codex-rs/thread-store/src/local/update_thread_metadata.rs b/codex-rs/thread-store/src/local/update_thread_metadata.rs index 580df1dc61..8362e844cf 100644 --- a/codex-rs/thread-store/src/local/update_thread_metadata.rs +++ b/codex-rs/thread-store/src/local/update_thread_metadata.rs @@ -83,7 +83,7 @@ pub(super) async fn update_thread_metadata( } if live_writer::rollout_path(store, thread_id).await.is_ok() { - live_writer::persist_thread(store, thread_id).await?; + live_writer::persist_history(store, thread_id).await?; } let mut resolved_rollout_path = resolve_rollout_path(store, thread_id, params.include_archived).await?;