From 10ca17496f5c934b9cf4baacda95c4a785f95630 Mon Sep 17 00:00:00 2001 From: Owen Lin Date: Fri, 20 Nov 2026 01:48:10 +0000 Subject: [PATCH] Pass inherited history visibility to the thread store (#62644) ## What changed Add `InheritedHistoryVisibility` to `CreateThreadParams` and pass it through prepared forks. `Full` is the default and remains the mode used by app-server forks. `ModelContextOnly` requests that `list_turns` and `list_items` omit inherited history. The local thread store rejects that mode as unsupported. ## Testing Add a regression test that requests `ModelContextOnly` through a prepared fork and checks that the local store's unsupported-operation error reaches the caller. GitOrigin-RevId: de675d6b83ca610eca5a304b9622b312d64828f6 --- .../session_importer.rs | 1 + .../request_processors/thread_processor.rs | 6 +++- .../tests/suite/conversation_summary.rs | 1 + .../tests/suite/v2/remote_thread_store.rs | 2 ++ .../app-server/tests/suite/v2/thread_read.rs | 3 ++ .../tests/suite/v2/thread_timeline.rs | 1 + .../tests/suite/v2/thread_unarchive.rs | 1 + codex-rs/core/src/session/mod.rs | 2 ++ codex-rs/core/src/session/session.rs | 9 +++++ codex-rs/core/src/session/tests.rs | 4 +++ codex-rs/core/src/thread_manager.rs | 3 ++ .../core/tests/suite/agent_control_tests.rs | 6 +++- codex-rs/core/tests/suite/agents_md.rs | 6 +++- codex-rs/core/tests/suite/fork_thread.rs | 35 +++++++++++++++++++ codex-rs/core/tests/suite/guardian_history.rs | 1 + .../tests/suite/guardian_retained_context.rs | 1 + .../suite/guardian_sender_messages_tests.rs | 6 +++- .../core/tests/suite/rollout_compression.rs | 1 + codex-rs/core/tests/suite/runtime_auth.rs | 1 + codex-rs/core/tests/suite/scenarios.rs | 6 +++- codex-rs/ext/guardian-v3/tests/evidence.rs | 1 + codex-rs/thread-store/src/in_memory.rs | 2 ++ codex-rs/thread-store/src/lib.rs | 1 + .../thread-store/src/local/live_writer.rs | 6 ++++ codex-rs/thread-store/src/local/mod.rs | 1 + .../local/pending_thread_metadata_tests.rs | 1 + .../src/local/revert_thread_tests.rs | 1 + .../thread_history_materialization_tests.rs | 2 ++ .../thread-store/src/thread_metadata_sync.rs | 1 + codex-rs/thread-store/src/types.rs | 14 ++++++++ 30 files changed, 121 insertions(+), 5 deletions(-) diff --git a/codex-rs/app-server/src/external_agent_migration/session_importer.rs b/codex-rs/app-server/src/external_agent_migration/session_importer.rs index 1a3613b434..069db42589 100644 --- a/codex-rs/app-server/src/external_agent_migration/session_importer.rs +++ b/codex-rs/app-server/src/external_agent_migration/session_importer.rs @@ -500,6 +500,7 @@ impl ExternalAgentSessionImporter { multi_agent_version: Some(MultiAgentVersion::V1), history_mode: ThreadHistoryMode::Legacy, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), metadata: ThreadPersistenceMetadata { diff --git a/codex-rs/app-server/src/request_processors/thread_processor.rs b/codex-rs/app-server/src/request_processors/thread_processor.rs index 556cc2cf05..84d30f6f7c 100644 --- a/codex-rs/app-server/src/request_processors/thread_processor.rs +++ b/codex-rs/app-server/src/request_processors/thread_processor.rs @@ -5906,7 +5906,11 @@ impl ThreadRequestProcessor { }; let new_thread = if let Some(prepared_fork) = prepared_fork { self.thread_manager - .fork_prepared_thread(fork_options, prepared_fork) + .fork_prepared_thread( + fork_options, + prepared_fork, + codex_thread_store::InheritedHistoryVisibility::Full, + ) .await } else { self.thread_manager diff --git a/codex-rs/app-server/tests/suite/conversation_summary.rs b/codex-rs/app-server/tests/suite/conversation_summary.rs index a1b6ee7bab..2747b2e40d 100644 --- a/codex-rs/app-server/tests/suite/conversation_summary.rs +++ b/codex-rs/app-server/tests/suite/conversation_summary.rs @@ -139,6 +139,7 @@ async fn get_conversation_summary_by_thread_id_reads_pathless_store_thread() -> multi_agent_version: None, history_mode: Default::default(), history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/app-server/tests/suite/v2/remote_thread_store.rs b/codex-rs/app-server/tests/suite/v2/remote_thread_store.rs index 6252312336..35f4849f06 100644 --- a/codex-rs/app-server/tests/suite/v2/remote_thread_store.rs +++ b/codex-rs/app-server/tests/suite/v2/remote_thread_store.rs @@ -302,6 +302,7 @@ async fn thread_list_repeated_cursor_returns_internal_error() -> Result<()> { multi_agent_version: None, history_mode: Default::default(), history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, @@ -554,6 +555,7 @@ async fn thread_delete_with_non_local_thread_store_does_not_create_local_persist multi_agent_version: None, history_mode: Default::default(), history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/app-server/tests/suite/v2/thread_read.rs b/codex-rs/app-server/tests/suite/v2/thread_read.rs index 151f86068f..d8097f4413 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_read.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_read.rs @@ -660,6 +660,7 @@ async fn thread_search_occurrences_reads_paginated_projection() -> Result<()> { multi_agent_version: None, history_mode: codex_protocol::protocol::ThreadHistoryMode::Paginated, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, @@ -3130,6 +3131,7 @@ async fn create_paginated_thread( multi_agent_version: None, history_mode: codex_protocol::protocol::ThreadHistoryMode::Paginated, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, @@ -3248,6 +3250,7 @@ async fn seed_pathless_store_thread( multi_agent_version: None, history_mode: Default::default(), history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/app-server/tests/suite/v2/thread_timeline.rs b/codex-rs/app-server/tests/suite/v2/thread_timeline.rs index aa8a1cd99c..61fc70d939 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_timeline.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_timeline.rs @@ -76,6 +76,7 @@ fn create_params(codex_home: &Path, thread_id: ThreadId) -> CreateThreadParams { multi_agent_version: None, history_mode: ThreadHistoryMode::Paginated, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/app-server/tests/suite/v2/thread_unarchive.rs b/codex-rs/app-server/tests/suite/v2/thread_unarchive.rs index a45211dcf2..b8de723839 100644 --- a/codex-rs/app-server/tests/suite/v2/thread_unarchive.rs +++ b/codex-rs/app-server/tests/suite/v2/thread_unarchive.rs @@ -264,6 +264,7 @@ async fn thread_unarchive_preserves_pathless_store_metadata() -> Result<()> { multi_agent_version: None, history_mode: Default::default(), history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/core/src/session/mod.rs b/codex-rs/core/src/session/mod.rs index ea069a2366..bb8f48c0d1 100644 --- a/codex-rs/core/src/session/mod.rs +++ b/codex-rs/core/src/session/mod.rs @@ -191,6 +191,7 @@ use codex_sandboxing::policy_transforms::intersect_permission_profiles_with_cont use codex_shell_command::parse_command::parse_command; use codex_terminal_detection::user_agent; use codex_thread_store::CreateThreadParams; +use codex_thread_store::InheritedHistoryVisibility; use codex_thread_store::LiveThread; use codex_thread_store::LiveThreadInitGuard; use codex_thread_store::LocalThreadStore; @@ -497,6 +498,7 @@ pub(crate) enum ForkPersistence { Referenced { history_base: Option, inherited_item_count: usize, + inherited_history_visibility: InheritedHistoryVisibility, }, } diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs index 5502b365f5..643cf7557a 100644 --- a/codex-rs/core/src/session/session.rs +++ b/codex-rs/core/src/session/session.rs @@ -1148,6 +1148,15 @@ impl Session { ForkPersistence::Copied | ForkPersistence::CopiedDeferred => None, ForkPersistence::Referenced { history_base, .. } => *history_base, }, + inherited_history_visibility: match &fork_persistence { + ForkPersistence::Copied | ForkPersistence::CopiedDeferred => { + InheritedHistoryVisibility::Full + } + ForkPersistence::Referenced { + inherited_history_visibility, + .. + } => *inherited_history_visibility, + }, subagent_history_start_ordinal: None, initial_window_id: ids.initial_window_id.clone(), runtime_workspace_roots: Some(config.workspace_roots.clone()), diff --git a/codex-rs/core/src/session/tests.rs b/codex-rs/core/src/session/tests.rs index c7217728b7..a09a604e53 100644 --- a/codex-rs/core/src/session/tests.rs +++ b/codex-rs/core/src/session/tests.rs @@ -4830,6 +4830,7 @@ async fn open_thread_persistence(session: &mut Session) -> PathBuf { history_mode: Default::default(), subagent_history_start_ordinal: None, history_base: None, + inherited_history_visibility: Default::default(), initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, metadata: ThreadPersistenceMetadata { @@ -8636,6 +8637,7 @@ async fn shutdown_complete_does_not_append_to_thread_store_after_shutdown() { history_mode: Default::default(), subagent_history_start_ordinal: None, history_base: None, + inherited_history_visibility: Default::default(), initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, metadata: ThreadPersistenceMetadata { @@ -8775,6 +8777,7 @@ async fn submission_loop_channel_close_runs_full_thread_teardown() -> anyhow::Re history_mode: Default::default(), subagent_history_start_ordinal: None, history_base: None, + inherited_history_visibility: Default::default(), initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, metadata: ThreadPersistenceMetadata { @@ -11773,6 +11776,7 @@ async fn attach_in_memory_thread_store( history_mode: Default::default(), subagent_history_start_ordinal: None, history_base: None, + inherited_history_visibility: Default::default(), initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, metadata: ThreadPersistenceMetadata { diff --git a/codex-rs/core/src/thread_manager.rs b/codex-rs/core/src/thread_manager.rs index 2b865977ad..23d9588888 100644 --- a/codex-rs/core/src/thread_manager.rs +++ b/codex-rs/core/src/thread_manager.rs @@ -110,6 +110,7 @@ use codex_protocol::protocol::W3cTraceContext; use codex_rollout::state_db::StateDbHandle; use codex_runtime_agent_instance::RuntimeAuthManager; use codex_skills_extension::HostSkillsService; +use codex_thread_store::InheritedHistoryVisibility; use codex_thread_store::LoadThreadHistoryParams; use codex_thread_store::LocalThreadStore; use codex_thread_store::LocalThreadStoreConfig; @@ -1919,6 +1920,7 @@ impl ThreadManager { &self, options: StartThreadOptions, prepared: PreparedFork, + inherited_history_visibility: InheritedHistoryVisibility, ) -> CodexResult { let history = InitialHistory::Resumed(ResumedHistory { history_revision: None, @@ -1929,6 +1931,7 @@ impl ThreadManager { let fork_persistence = ForkPersistence::Referenced { history_base: prepared.history_base, inherited_item_count: prepared.model_context.len(), + inherited_history_visibility, }; let result = self .fork_thread_with_initial_history( diff --git a/codex-rs/core/tests/suite/agent_control_tests.rs b/codex-rs/core/tests/suite/agent_control_tests.rs index c1ccf38951..876f8f6591 100644 --- a/codex-rs/core/tests/suite/agent_control_tests.rs +++ b/codex-rs/core/tests/suite/agent_control_tests.rs @@ -723,7 +723,11 @@ async fn hosted_child_persists_inherited_session_id( }) .await?; manager - .fork_prepared_thread(child_options, prepared) + .fork_prepared_thread( + child_options, + prepared, + codex_thread_store::InheritedHistoryVisibility::Full, + ) .await? } }; diff --git a/codex-rs/core/tests/suite/agents_md.rs b/codex-rs/core/tests/suite/agents_md.rs index fb0fdde340..64cb51e693 100644 --- a/codex-rs/core/tests/suite/agents_md.rs +++ b/codex-rs/core/tests/suite/agents_md.rs @@ -1612,7 +1612,11 @@ async fn fork_preserves_thread_instructions( }) .await?; test.thread_manager - .fork_prepared_thread(options, prepared) + .fork_prepared_thread( + options, + prepared, + codex_thread_store::InheritedHistoryVisibility::Full, + ) .await? } }; diff --git a/codex-rs/core/tests/suite/fork_thread.rs b/codex-rs/core/tests/suite/fork_thread.rs index 044cacd9a2..e13ef3f400 100644 --- a/codex-rs/core/tests/suite/fork_thread.rs +++ b/codex-rs/core/tests/suite/fork_thread.rs @@ -8,6 +8,7 @@ use codex_history::InitialHistory; use codex_history::ResumedHistory; use codex_history::RolloutItem; use codex_protocol::ThreadId; +use codex_protocol::error::CodexErrorDetails; use codex_protocol::items::TurnItem; use codex_protocol::mcp::ClientMcpExtensions; use codex_protocol::protocol::EventMsg; @@ -17,6 +18,8 @@ use codex_protocol::protocol::ThreadSettingsOverrides; use codex_protocol::protocol::ThreadSettingsSnapshot; use codex_protocol::user_input::UserInput; use codex_thread_store::InMemoryThreadStore; +use codex_thread_store::InheritedHistoryVisibility; +use codex_thread_store::PreparedFork; use core_test_support::responses::ev_completed; use core_test_support::responses::ev_response_created; use core_test_support::responses::sse; @@ -31,6 +34,38 @@ use wiremock::ResponseTemplate; use wiremock::matchers::method; use wiremock::matchers::path; +#[tokio::test(flavor = "multi_thread", worker_threads = 2)] +async fn prepared_fork_passes_inherited_history_visibility_to_store() -> anyhow::Result<()> { + skip_if_no_network!(Ok(())); + + let server = MockServer::start().await; + let test = test_codex().build_with_auto_env(&server).await?; + let prepared = PreparedFork::with_source_revalidation( + test.session_configured.thread_id, + /*history_base*/ None, + Arc::new(Vec::new()), + ); + + let result = test + .thread_manager + .fork_prepared_thread( + test.start_thread_options().await, + prepared, + InheritedHistoryVisibility::ModelContextOnly, + ) + .await; + + match result { + Err(error) => assert!(matches!( + error.details(), + CodexErrorDetails::UnsupportedOperation(message) + if message == "model_context_only_inherited_history is not supported yet" + )), + Ok(_) => anyhow::bail!("expected local thread store to reject hidden inherited history"), + } + Ok(()) +} + #[tokio::test(flavor = "multi_thread", worker_threads = 2)] async fn ephemeral_fork_skips_stored_title_lookup() -> anyhow::Result<()> { skip_if_no_network!(Ok(())); diff --git a/codex-rs/core/tests/suite/guardian_history.rs b/codex-rs/core/tests/suite/guardian_history.rs index cf86b062cc..1f724d1ccc 100644 --- a/codex-rs/core/tests/suite/guardian_history.rs +++ b/codex-rs/core/tests/suite/guardian_history.rs @@ -131,6 +131,7 @@ async fn guardian_history_survives_restart_and_user_fork( .fork_prepared_thread( codex_core::StartThreadOptions::new(initial.config.clone()), prepared, + codex_thread_store::InheritedHistoryVisibility::Full, ) .await? } else { diff --git a/codex-rs/core/tests/suite/guardian_retained_context.rs b/codex-rs/core/tests/suite/guardian_retained_context.rs index d6904fa094..59b03bb5f1 100644 --- a/codex-rs/core/tests/suite/guardian_retained_context.rs +++ b/codex-rs/core/tests/suite/guardian_retained_context.rs @@ -984,6 +984,7 @@ async fn standalone_fork_retains_inherited_user_instructions( .fork_prepared_thread( codex_core::StartThreadOptions::new(test.config.clone()), prepared, + codex_thread_store::InheritedHistoryVisibility::Full, ) .await? } else { diff --git a/codex-rs/core/tests/suite/guardian_sender_messages_tests.rs b/codex-rs/core/tests/suite/guardian_sender_messages_tests.rs index f6f5073a7a..25b35c1225 100644 --- a/codex-rs/core/tests/suite/guardian_sender_messages_tests.rs +++ b/codex-rs/core/tests/suite/guardian_sender_messages_tests.rs @@ -248,7 +248,11 @@ async fn stored_fork_sender_evidence_matches_live_sender() -> Result<()> { .insert(RestrictRootCapabilities); let sender = root .thread_manager - .fork_prepared_thread(options, prepared) + .fork_prepared_thread( + options, + prepared, + codex_thread_store::InheritedHistoryVisibility::Full, + ) .await?; responses::mount_sse_once( &server, diff --git a/codex-rs/core/tests/suite/rollout_compression.rs b/codex-rs/core/tests/suite/rollout_compression.rs index cf542007a9..9e6bcf1539 100644 --- a/codex-rs/core/tests/suite/rollout_compression.rs +++ b/codex-rs/core/tests/suite/rollout_compression.rs @@ -90,6 +90,7 @@ async fn compressed_shared_fork_resume_preserves_checkpoint_and_frozen_history() .fork_prepared_thread( codex_core::StartThreadOptions::new(test.config.clone()), prepared, + codex_thread_store::InheritedHistoryVisibility::Full, ) .await?; turn( diff --git a/codex-rs/core/tests/suite/runtime_auth.rs b/codex-rs/core/tests/suite/runtime_auth.rs index 1c49cc3676..afb166660c 100644 --- a/codex-rs/core/tests/suite/runtime_auth.rs +++ b/codex-rs/core/tests/suite/runtime_auth.rs @@ -434,6 +434,7 @@ async fn exercise_harness(server_uri: String) -> Result<()> { ..StartThreadOptions::new(child_config.clone()) }, prepared, + codex_thread_store::InheritedHistoryVisibility::Full, ) .await?; turn(&child.thread, "child-assertion").await?; diff --git a/codex-rs/core/tests/suite/scenarios.rs b/codex-rs/core/tests/suite/scenarios.rs index 68a9b81262..2737b33fdb 100644 --- a/codex-rs/core/tests/suite/scenarios.rs +++ b/codex-rs/core/tests/suite/scenarios.rs @@ -3558,7 +3558,11 @@ async fn attached_side_chat_preserves_model_context_on_cold_resume() -> Result<( resume_options.environments = options.environments.clone(); let child = test .thread_manager - .fork_prepared_thread(options, prepared) + .fork_prepared_thread( + options, + prepared, + codex_thread_store::InheritedHistoryVisibility::Full, + ) .await?; child .thread diff --git a/codex-rs/ext/guardian-v3/tests/evidence.rs b/codex-rs/ext/guardian-v3/tests/evidence.rs index 7e38340bb2..67bc6f59ac 100644 --- a/codex-rs/ext/guardian-v3/tests/evidence.rs +++ b/codex-rs/ext/guardian-v3/tests/evidence.rs @@ -66,6 +66,7 @@ async fn captures_originals_without_generated_context_or_later_appends() -> anyh multi_agent_version: None, history_mode: ThreadHistoryMode::Paginated, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/thread-store/src/in_memory.rs b/codex-rs/thread-store/src/in_memory.rs index 35d71b5f93..de4a4844e5 100644 --- a/codex-rs/thread-store/src/in_memory.rs +++ b/codex-rs/thread-store/src/in_memory.rs @@ -185,6 +185,7 @@ mod tests { multi_agent_version: None, history_mode: ThreadHistoryMode::Legacy, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, @@ -466,6 +467,7 @@ mod tests { multi_agent_version: None, history_mode, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/thread-store/src/lib.rs b/codex-rs/thread-store/src/lib.rs index 6cef8653e3..f3e05ba294 100644 --- a/codex-rs/thread-store/src/lib.rs +++ b/codex-rs/thread-store/src/lib.rs @@ -90,6 +90,7 @@ pub use types::DeleteThreadsParams; pub use types::ExtraConfig; pub use types::ForkBoundary; pub use types::GitInfoPatch; +pub use types::InheritedHistoryVisibility; pub use types::ItemPage; pub use types::ItemSortKey; pub use types::ListItemsParams; diff --git a/codex-rs/thread-store/src/local/live_writer.rs b/codex-rs/thread-store/src/local/live_writer.rs index 0c968163ca..c408b9630d 100644 --- a/codex-rs/thread-store/src/local/live_writer.rs +++ b/codex-rs/thread-store/src/local/live_writer.rs @@ -16,6 +16,7 @@ use super::LocalThreadStore; use super::create_thread; use crate::AppendThreadItemsParams; use crate::CreateThreadParams; +use crate::InheritedHistoryVisibility; use crate::ResumeThreadParams; use crate::ThreadStoreError; use crate::ThreadStoreResult; @@ -27,6 +28,11 @@ pub(super) async fn create_thread( store: &LocalThreadStore, params: CreateThreadParams, ) -> ThreadStoreResult<()> { + if params.inherited_history_visibility == InheritedHistoryVisibility::ModelContextOnly { + return Err(ThreadStoreError::Unsupported { + operation: "model_context_only_inherited_history", + }); + } let thread_id = params.thread_id; let inherited_cursor = if params.initial_window_id.allocation().is_some() && let (Some(parent), Some(base)) = (params.forked_from_id, params.history_base) diff --git a/codex-rs/thread-store/src/local/mod.rs b/codex-rs/thread-store/src/local/mod.rs index 006d8c6b8d..44c67c94b5 100644 --- a/codex-rs/thread-store/src/local/mod.rs +++ b/codex-rs/thread-store/src/local/mod.rs @@ -2609,6 +2609,7 @@ mod tests { multi_agent_version: None, history_mode: ThreadHistoryMode::Legacy, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/thread-store/src/local/pending_thread_metadata_tests.rs b/codex-rs/thread-store/src/local/pending_thread_metadata_tests.rs index 156ecc8cb5..8de70b5f07 100644 --- a/codex-rs/thread-store/src/local/pending_thread_metadata_tests.rs +++ b/codex-rs/thread-store/src/local/pending_thread_metadata_tests.rs @@ -656,6 +656,7 @@ fn create_thread_params(thread_id: ThreadId) -> CreateThreadParams { multi_agent_version: None, history_mode: ThreadHistoryMode::Legacy, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/thread-store/src/local/revert_thread_tests.rs b/codex-rs/thread-store/src/local/revert_thread_tests.rs index 8bfeb04322..2b3368be8f 100644 --- a/codex-rs/thread-store/src/local/revert_thread_tests.rs +++ b/codex-rs/thread-store/src/local/revert_thread_tests.rs @@ -367,6 +367,7 @@ async fn create_paginated_thread(store: &LocalThreadStore, thread_id: ThreadId) multi_agent_version: None, history_mode: ThreadHistoryMode::Paginated, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: Some(vec![store.config.codex_home.join("workspace").abs()]), diff --git a/codex-rs/thread-store/src/local/thread_history_materialization_tests.rs b/codex-rs/thread-store/src/local/thread_history_materialization_tests.rs index 7612fc930e..7a18b45b8d 100644 --- a/codex-rs/thread-store/src/local/thread_history_materialization_tests.rs +++ b/codex-rs/thread-store/src/local/thread_history_materialization_tests.rs @@ -815,6 +815,7 @@ async fn paginated_realtime_items_materialize_separately_in_rollout_order() { multi_agent_version: None, history_mode: ThreadHistoryMode::Legacy, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, @@ -3167,6 +3168,7 @@ async fn create_paginated_subagent_thread( multi_agent_version: None, history_mode: ThreadHistoryMode::Paginated, history_base, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/thread-store/src/thread_metadata_sync.rs b/codex-rs/thread-store/src/thread_metadata_sync.rs index c972769cec..769c9c91c7 100644 --- a/codex-rs/thread-store/src/thread_metadata_sync.rs +++ b/codex-rs/thread-store/src/thread_metadata_sync.rs @@ -507,6 +507,7 @@ mod tests { multi_agent_version: None, history_mode: ThreadHistoryMode::Legacy, history_base: None, + inherited_history_visibility: Default::default(), subagent_history_start_ordinal: None, initial_window_id: codex_protocol::ContextWindowId::new_uuid_v7(), runtime_workspace_roots: None, diff --git a/codex-rs/thread-store/src/types.rs b/codex-rs/thread-store/src/types.rs index ef98de57e8..a9a5d528eb 100644 --- a/codex-rs/thread-store/src/types.rs +++ b/codex-rs/thread-store/src/types.rs @@ -70,6 +70,17 @@ pub struct ThreadPersistenceMetadata { #[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] pub struct ExtraConfig {} +/// Controls whether history inherited from a fork's source thread is returned by `list_turns` +/// and `list_items`. +#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize)] +pub enum InheritedHistoryVisibility { + /// Include inherited history in `list_turns` and `list_items`. + #[default] + Full, + /// Omit inherited history from `list_turns` and `list_items`. + ModelContextOnly, +} + /// Parameters required to create a persisted thread. #[derive(Clone, Debug, Serialize, Deserialize)] pub struct CreateThreadParams { @@ -111,6 +122,9 @@ pub struct CreateThreadParams { pub history_mode: ThreadHistoryMode, /// Exclusive prefix of another paginated rollout inherited by this thread. pub history_base: Option, + /// Visibility of the history inherited through `history_base`. + #[serde(default)] + pub inherited_history_visibility: InheritedHistoryVisibility, /// First rollout ordinal that belongs to this subagent's projected history. pub subagent_history_start_ordinal: Option, /// Initial context-window identity captured when the thread was created.