Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

Add extra config to StoredThread, leave empty for now (#27092)

Boyang Niue127a0cf9919
diff --git a/codex-rs/app-server/src/bespoke_event_handling.rs b/codex-rs/app-server/src/bespoke_event_handling.rs
index 4549eab68d..d4d6f59349 100644
--- a/codex-rs/app-server/src/bespoke_event_handling.rs
+++ b/codex-rs/app-server/src/bespoke_event_handling.rs
@@ -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,
diff --git a/codex-rs/app-server/src/request_processors/external_agent_session_import.rs b/codex-rs/app-server/src/request_processors/external_agent_session_import.rs
index 163210f164..4cec9bca16 100644
--- a/codex-rs/app-server/src/request_processors/external_agent_session_import.rs
+++ b/codex-rs/app-server/src/request_processors/external_agent_session_import.rs
@@ -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(),
diff --git a/codex-rs/app-server/src/request_processors/thread_processor_tests.rs b/codex-rs/app-server/src/request_processors/thread_processor_tests.rs
index 49941dd839..54c0f0343f 100644
--- a/codex-rs/app-server/src/request_processors/thread_processor_tests.rs
+++ b/codex-rs/app-server/src/request_processors/thread_processor_tests.rs
@@ -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,
diff --git a/codex-rs/app-server/tests/suite/conversation_summary.rs b/codex-rs/app-server/tests/suite/conversation_summary.rs
index 05e3ad1c77..6ad9f1c633 100644
--- a/codex-rs/app-server/tests/suite/conversation_summary.rs
+++ b/codex-rs/app-server/tests/suite/conversation_summary.rs
@@ -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,
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 0a99d30ada..272ecac79f 100644
--- a/codex-rs/app-server/tests/suite/v2/thread_read.rs
+++ b/codex-rs/app-server/tests/suite/v2/thread_read.rs
@@ -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,
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 84fffd19ba..7267ab073a 100644
--- a/codex-rs/app-server/tests/suite/v2/thread_unarchive.rs
+++ b/codex-rs/app-server/tests/suite/v2/thread_unarchive.rs
@@ -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,
diff --git a/codex-rs/core-api/src/lib.rs b/codex-rs/core-api/src/lib.rs
index d1c7c7a18b..47452eb032 100644
--- a/codex-rs/core-api/src/lib.rs
+++ b/codex-rs/core-api/src/lib.rs
@@ -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;
diff --git a/codex-rs/core/src/config/mod.rs b/codex-rs/core/src/config/mod.rs
index 3f7a7370a0..93e203053f 100644
--- a/codex-rs/core/src/config/mod.rs
+++ b/codex-rs/core/src/config/mod.rs
@@ -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;
@@ -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.
@@ -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,
diff --git a/codex-rs/core/src/realtime_context_tests.rs b/codex-rs/core/src/realtime_context_tests.rs
index 8e74599897..8c3aa8d97e 100644
--- a/codex-rs/core/src/realtime_context_tests.rs
+++ b/codex-rs/core/src/realtime_context_tests.rs
@@ -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,
diff --git a/codex-rs/core/src/session/session.rs b/codex-rs/core/src/session/session.rs
index 37a501fb38..c6d0d9767e 100644
--- a/codex-rs/core/src/session/session.rs
+++ b/codex-rs/core/src/session/session.rs
@@ -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,
diff --git a/codex-rs/core/src/session/tests.rs b/codex-rs/core/src/session/tests.rs
index d44c7fbdcc..ef3f6dbfba 100644
--- a/codex-rs/core/src/session/tests.rs
+++ b/codex-rs/core/src/session/tests.rs
@@ -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,
@@ -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,
diff --git a/codex-rs/thread-manager-sample/src/main.rs b/codex-rs/thread-manager-sample/src/main.rs
index 91fd7a0b3e..5ffb8c4c0d 100644
--- a/codex-rs/thread-manager-sample/src/main.rs
+++ b/codex-rs/thread-manager-sample/src/main.rs
@@ -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,
diff --git a/codex-rs/thread-store/src/in_memory.rs b/codex-rs/thread-store/src/in_memory.rs
index 3a44c26b32..edc308a905 100644
--- a/codex-rs/thread-store/src/in_memory.rs
+++ b/codex-rs/thread-store/src/in_memory.rs
@@ -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),
diff --git a/codex-rs/thread-store/src/lib.rs b/codex-rs/thread-store/src/lib.rs
index 157d13004f..84b72f23f0 100644
--- a/codex-rs/thread-store/src/lib.rs
+++ b/codex-rs/thread-store/src/lib.rs
@@ -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;
diff --git a/codex-rs/thread-store/src/local/helpers.rs b/codex-rs/thread-store/src/local/helpers.rs
index ae0650855a..5acdcf09b6 100644
--- a/codex-rs/thread-store/src/local/helpers.rs
+++ b/codex-rs/thread-store/src/local/helpers.rs
@@ -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,
diff --git a/codex-rs/thread-store/src/local/mod.rs b/codex-rs/thread-store/src/local/mod.rs
index 146bfbd843..cef4496a02 100644
--- a/codex-rs/thread-store/src/local/mod.rs
+++ b/codex-rs/thread-store/src/local/mod.rs
@@ -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,
diff --git a/codex-rs/thread-store/src/local/read_thread.rs b/codex-rs/thread-store/src/local/read_thread.rs
index 52c8eb7a38..24bc32993c 100644
--- a/codex-rs/thread-store/src/local/read_thread.rs
+++ b/codex-rs/thread-store/src/local/read_thread.rs
@@ -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,
rollout_path: Some(rollout_path),
forked_from_id,
parent_thread_id,
@@ -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,
diff --git a/codex-rs/thread-store/src/types.rs b/codex-rs/thread-store/src/types.rs
index 1ab42a3117..1f18adf081 100644
--- a/codex-rs/thread-store/src/types.rs
+++ b/codex-rs/thread-store/src/types.rs
@@ -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.
@@ -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.