Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions codex-rs/app-server/src/bespoke_event_handling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2181,6 +2181,7 @@ mod tests {
];
let stored_thread = StoredThread {
thread_id,
extra_config: None,
rollout_path: None,
forked_from_id: None,
parent_thread_id: None,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ impl ExternalAgentSessionImporter {
let now = Utc::now();
let create_params = CreateThreadParams {
thread_id,
extra_config: None,
forked_from_id: None,
parent_thread_id: None,
source: source.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,7 @@ mod thread_processor_behavior_tests {
ThreadId::from_string("00000000-0000-0000-0000-000000000123").expect("valid thread");
let stored_thread = StoredThread {
thread_id,
extra_config: None,
rollout_path: Some(PathBuf::from("/tmp/thread.jsonl")),
forked_from_id: None,
parent_thread_id: None,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/app-server/tests/suite/conversation_summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ async fn get_conversation_summary_by_thread_id_reads_pathless_store_thread() ->
store
.create_thread(CreateThreadParams {
thread_id,
extra_config: None,
forked_from_id: None,
parent_thread_id: None,
source: SessionSource::Cli,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/app-server/tests/suite/v2/thread_read.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1356,6 +1356,7 @@ async fn seed_pathless_store_thread(
store
.create_thread(CreateThreadParams {
thread_id,
extra_config: None,
forked_from_id: None,
parent_thread_id: None,
source: ProtocolSessionSource::Cli,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/app-server/tests/suite/v2/thread_unarchive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ async fn thread_unarchive_preserves_pathless_store_metadata() -> Result<()> {
store
.create_thread(CreateThreadParams {
thread_id,
extra_config: None,
forked_from_id: Some(parent_thread_id),
parent_thread_id: None,
source: SessionSource::Cli,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core-api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ pub use codex_core::ThreadManager;
pub use codex_core::ThreadShutdownReport;
pub use codex_core::config::Config;
pub use codex_core::config::Constrained;
pub use codex_core::config::ExtraConfig;
pub use codex_core::config::GhostSnapshotConfig;
pub use codex_core::config::MultiAgentV2Config;
pub use codex_core::config::Permissions;
Expand Down
5 changes: 5 additions & 0 deletions codex-rs/core/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ use codex_protocol::permissions::NetworkSandboxPolicy;
use codex_protocol::protocol::AskForApproval;
use codex_protocol::protocol::MultiAgentVersion;
use codex_protocol::protocol::SandboxPolicy;
pub use codex_thread_store::ExtraConfig;
use codex_utils_absolute_path::AbsolutePathBuf;
use codex_utils_absolute_path::AbsolutePathBufGuard;
use rmcp::model::ElicitationCapability;
Expand Down Expand Up @@ -870,6 +871,9 @@ pub struct Config {
/// When true, session is not persisted on disk. Default to `false`
pub ephemeral: bool,

/// Optional extra configuration fields for the thread.
pub extra_config: Option<ExtraConfig>,

/// Whether enabled hooks should run without requiring persisted hook trust for this session.
///
/// This is a runtime-only knob populated from invocation overrides, not from config files.
Expand Down Expand Up @@ -3525,6 +3529,7 @@ impl Config {
config_layer_stack,
history,
ephemeral: ephemeral.unwrap_or_default(),
extra_config: None,
bypass_hook_trust,
file_opener: cfg.file_opener.unwrap_or(UriBasedFileOpener::VsCode),
codex_self_exe,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/realtime_context_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use tempfile::TempDir;
fn stored_thread(cwd: &str, title: &str, first_user_message: &str) -> StoredThread {
StoredThread {
thread_id: ThreadId::new(),
extra_config: None,
rollout_path: Some(PathBuf::from("/tmp/rollout.jsonl")),
forked_from_id: None,
parent_thread_id: None,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/core/src/session/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ impl Session {
Arc::clone(&thread_store),
CreateThreadParams {
thread_id,
extra_config: config.extra_config.clone(),
forked_from_id,
parent_thread_id,
source: session_source,
Expand Down
2 changes: 2 additions & 0 deletions codex-rs/core/src/session/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3526,6 +3526,7 @@ async fn attach_thread_persistence(session: &mut Session) -> PathBuf {
Arc::clone(&session.services.thread_store),
CreateThreadParams {
thread_id: session.thread_id,
extra_config: None,
forked_from_id: None,
parent_thread_id: None,
source: SessionSource::Exec,
Expand Down Expand Up @@ -6360,6 +6361,7 @@ async fn shutdown_complete_does_not_append_to_thread_store_after_shutdown() {
Arc::clone(&thread_store),
CreateThreadParams {
thread_id: session.thread_id,
extra_config: None,
forked_from_id: None,
parent_thread_id: None,
source: SessionSource::Exec,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/thread-manager-sample/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ fn new_config(model: Option<String>, arg0_paths: Arg0DispatchPaths) -> anyhow::R
codex_home,
history: History::default(),
ephemeral: true,
extra_config: None,
file_opener: UriBasedFileOpener::VsCode,
codex_self_exe: arg0_paths.codex_self_exe,
codex_linux_sandbox_exe: arg0_paths.codex_linux_sandbox_exe,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/thread-store/src/in_memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ fn stored_thread_from_state(

Ok(StoredThread {
thread_id,
extra_config: created.extra_config.clone(),
rollout_path: metadata
.and_then(|metadata| metadata.rollout_path.clone())
.or(rollout_path),
Expand Down
1 change: 1 addition & 0 deletions codex-rs/thread-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ pub use types::AppendThreadItemsParams;
pub use types::ArchiveThreadParams;
pub use types::ClearableField;
pub use types::CreateThreadParams;
pub use types::ExtraConfig;
pub use types::GitInfoPatch;
pub use types::ItemPage;
pub use types::ListItemsParams;
Expand Down
1 change: 1 addition & 0 deletions codex-rs/thread-store/src/local/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ pub(super) fn stored_thread_from_rollout_item(

Some(StoredThread {
thread_id,
extra_config: None,
rollout_path: Some(rollout_path),
forked_from_id: None,
parent_thread_id: item.parent_thread_id,
Expand Down
1 change: 1 addition & 0 deletions codex-rs/thread-store/src/local/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1013,6 +1013,7 @@ mod tests {
fn create_thread_params(thread_id: ThreadId) -> CreateThreadParams {
CreateThreadParams {
thread_id,
extra_config: None,
forked_from_id: None,
parent_thread_id: None,
source: SessionSource::Exec,
Expand Down
2 changes: 2 additions & 0 deletions codex-rs/thread-store/src/local/read_thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ async fn stored_thread_from_sqlite_metadata(
permission_profile_from_metadata_value(&metadata.sandbox_policy, metadata.cwd.as_path());
StoredThread {
thread_id: metadata.id,
extra_config: None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve extra config in local thread reads

When a caller starts a session with config.extra_config = Some(...), Session now passes it into CreateThreadParams, but the default local store reconstructs every StoredThread with extra_config: None. That makes the new StoredThread.extra_config field observable only in the in-memory test store and drops it for real persisted threads after any read/list/resume path, so consumers cannot rely on the field surviving thread creation.

Useful? React with 👍 / 👎.

rollout_path: Some(rollout_path),
forked_from_id,
parent_thread_id,
Expand Down Expand Up @@ -390,6 +391,7 @@ fn stored_thread_from_meta_line(
let rollout_path = codex_rollout::plain_rollout_path(path.as_path());
StoredThread {
thread_id: meta_line.meta.id,
extra_config: None,
rollout_path: Some(rollout_path),
forked_from_id: meta_line.meta.forked_from_id,
parent_thread_id: meta_line.meta.parent_thread_id,
Expand Down
8 changes: 8 additions & 0 deletions codex-rs/thread-store/src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,17 @@ pub struct ThreadPersistenceMetadata {
pub memory_mode: MemoryMode,
}

/// Extra configuration fields for a thread.
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExtraConfig {}

/// Parameters required to create a persisted thread.
#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CreateThreadParams {
/// Thread id generated by Codex before opening persistence.
pub thread_id: ThreadId,
/// Optional extra configuration fields for the thread.
pub extra_config: Option<ExtraConfig>,
/// Source thread id when this thread is created as a fork.
pub forked_from_id: Option<ThreadId>,
/// The ID of the parent thread. This will only be set if this thread is a subagent.
Expand Down Expand Up @@ -349,6 +355,8 @@ pub struct ItemPage {
pub struct StoredThread {
/// Thread id.
pub thread_id: ThreadId,
/// Optional extra configuration fields for the thread.
pub extra_config: Option<ExtraConfig>,
/// Local rollout path when the backing store is filesystem-based.
pub rollout_path: Option<PathBuf>,
/// Source thread id when this thread was forked from another thread.
Expand Down
Loading