mirror of
https://github.com/openai/codex.git
synced 2026-11-03 08:22:30 +00:00
[codex] Migrate thread turns list to thread store (#19280)
- migrate `thread/turns/list` to ThreadStore. Uses ThreadStore for most data now but merges in the in-memory state from thread manager - keep v2 `thread/list` pathless-store friendly by converting `StoredThread` directly to API `Thread` - add regression coverage for pathless store history/listing
This commit is contained in:
12 files changed
+713
-192
No files matched your search
@@ -31,6 +31,9 @@ use codex_protocol::protocol::ThreadMemoryMode;
|
||||
use codex_protocol::protocol::TokenUsageInfo;
|
||||
use codex_protocol::protocol::W3cTraceContext;
|
||||
use codex_protocol::user_input::UserInput;
|
||||
use codex_thread_store::StoredThreadHistory;
|
||||
use codex_thread_store::ThreadStoreError;
|
||||
use codex_thread_store::ThreadStoreResult;
|
||||
use codex_utils_absolute_path::AbsolutePathBuf;
|
||||
use rmcp::model::ReadResourceRequestParams;
|
||||
use std::collections::HashMap;
|
||||
@@ -382,6 +385,20 @@ impl CodexThread {
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn load_history(
|
||||
&self,
|
||||
include_archived: bool,
|
||||
) -> ThreadStoreResult<StoredThreadHistory> {
|
||||
let live_thread = self
|
||||
.codex
|
||||
.session
|
||||
.live_thread_for_persistence("load history")
|
||||
.map_err(|err| ThreadStoreError::Internal {
|
||||
message: err.to_string(),
|
||||
})?;
|
||||
live_thread.load_history(include_archived).await
|
||||
}
|
||||
|
||||
pub fn state_db(&self) -> Option<StateDbHandle> {
|
||||
self.codex.state_db()
|
||||
}
|
||||
|
||||
@@ -375,8 +375,7 @@ pub enum ThreadStoreConfig {
|
||||
Local,
|
||||
/// Persist threads through the remote thread-store service.
|
||||
Remote { endpoint: String },
|
||||
/// Test-only in-memory thread store.
|
||||
#[cfg(debug_assertions)]
|
||||
/// In-memory thread store for test and debug configurations.
|
||||
InMemory { id: String },
|
||||
}
|
||||
|
||||
@@ -1586,7 +1585,6 @@ fn thread_store_config(
|
||||
match thread_store {
|
||||
Some(ThreadStoreToml::Local {}) => ThreadStoreConfig::Local,
|
||||
Some(ThreadStoreToml::Remote { endpoint }) => ThreadStoreConfig::Remote { endpoint },
|
||||
#[cfg(debug_assertions)]
|
||||
Some(ThreadStoreToml::InMemory { id }) => ThreadStoreConfig::InMemory { id },
|
||||
None => legacy_remote_endpoint.map_or(ThreadStoreConfig::Local, |endpoint| {
|
||||
ThreadStoreConfig::Remote { endpoint }
|
||||
|
||||
@@ -52,7 +52,6 @@ use codex_protocol::protocol::TurnEnvironmentSelection;
|
||||
use codex_protocol::protocol::W3cTraceContext;
|
||||
use codex_rollout::RolloutConfig;
|
||||
use codex_state::DirectionalThreadSpawnEdgeStatus;
|
||||
#[cfg(debug_assertions)]
|
||||
use codex_thread_store::InMemoryThreadStore;
|
||||
use codex_thread_store::LocalThreadStore;
|
||||
use codex_thread_store::RemoteThreadStore;
|
||||
@@ -268,7 +267,6 @@ pub fn thread_store_from_config(config: &Config) -> Arc<dyn ThreadStore> {
|
||||
Arc::new(LocalThreadStore::new(RolloutConfig::from_view(config)))
|
||||
}
|
||||
ThreadStoreConfig::Remote { endpoint } => Arc::new(RemoteThreadStore::new(endpoint)),
|
||||
#[cfg(debug_assertions)]
|
||||
ThreadStoreConfig::InMemory { id } => InMemoryThreadStore::for_id(id),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user