mirror of
https://github.com/openai/codex.git
synced 2026-05-21 11:42:55 +00:00
## Why Whenever we return a thread's history (turns and items) over app-server, always return the limited form as specified by the rollout policy `EventPersistenceMode::Limited`, even if the thread was previously started with `EventPersistenceMode::Extended`. We're finding it is quite unscalable to be returning the extended history, so let's apply the same filtering logic of the rollout policy when we load and return the thread's history. ## What Changed - Reuse the rollout persistence policy when reconstructing app-server `ThreadItem` history so only `EventPersistenceMode::Limited` rollout items are replayed into API turns. - Route `thread/read`, `thread/resume`, `thread/fork`, `thread/turns/list`, and rollback responses through the same filtered app-server history projection. - Keep live active turns intact when composing a response for a currently running thread. - Update command execution coverage so persisted extended command events are excluded from returned history for `thread/read`, `thread/fork`, and `thread/turns/list`. ## Test Plan - `cargo test -p codex-app-server limited` - `cargo test -p codex-app-server thread_shell_command` - `cargo test -p codex-app-server thread_read` - `cargo test -p codex-app-server thread_rollback` - `cargo test -p codex-app-server thread_fork` - `cargo test -p codex-app-server-protocol`
69 lines
2.1 KiB
Rust
69 lines
2.1 KiB
Rust
//! Rollout persistence and discovery for Codex session files.
|
|
|
|
use std::sync::LazyLock;
|
|
|
|
use codex_protocol::protocol::SessionSource;
|
|
|
|
pub(crate) mod config;
|
|
pub(crate) mod list;
|
|
pub(crate) mod metadata;
|
|
pub(crate) mod policy;
|
|
pub(crate) mod recorder;
|
|
pub(crate) mod session_index;
|
|
pub mod state_db;
|
|
|
|
pub(crate) mod default_client {
|
|
pub use codex_login::default_client::*;
|
|
}
|
|
|
|
pub(crate) use codex_protocol::protocol;
|
|
|
|
pub const SESSIONS_SUBDIR: &str = "sessions";
|
|
pub const ARCHIVED_SESSIONS_SUBDIR: &str = "archived_sessions";
|
|
pub static INTERACTIVE_SESSION_SOURCES: LazyLock<Vec<SessionSource>> = LazyLock::new(|| {
|
|
vec![
|
|
SessionSource::Cli,
|
|
SessionSource::VSCode,
|
|
SessionSource::Custom("atlas".to_string()),
|
|
SessionSource::Custom("chatgpt".to_string()),
|
|
]
|
|
});
|
|
|
|
pub use codex_protocol::protocol::SessionMeta;
|
|
pub use config::Config;
|
|
pub use config::RolloutConfig;
|
|
pub use config::RolloutConfigView;
|
|
pub use list::Cursor;
|
|
pub use list::SortDirection;
|
|
pub use list::ThreadItem;
|
|
pub use list::ThreadListConfig;
|
|
pub use list::ThreadListLayout;
|
|
pub use list::ThreadSortKey;
|
|
pub use list::ThreadsPage;
|
|
pub use list::find_archived_thread_path_by_id_str;
|
|
pub use list::find_thread_path_by_id_str;
|
|
#[deprecated(note = "use find_thread_path_by_id_str")]
|
|
pub use list::find_thread_path_by_id_str as find_conversation_path_by_id_str;
|
|
pub use list::get_threads;
|
|
pub use list::get_threads_in_root;
|
|
pub use list::parse_cursor;
|
|
pub use list::read_head_for_summary;
|
|
pub use list::read_session_meta_line;
|
|
pub use list::read_thread_item_from_rollout;
|
|
pub use list::rollout_date_parts;
|
|
pub use metadata::builder_from_items;
|
|
pub use policy::EventPersistenceMode;
|
|
pub use policy::is_persisted_rollout_item;
|
|
pub use policy::should_persist_response_item_for_memories;
|
|
pub use recorder::RolloutRecorder;
|
|
pub use recorder::RolloutRecorderParams;
|
|
pub use recorder::append_rollout_item_to_path;
|
|
pub use session_index::append_thread_name;
|
|
pub use session_index::find_thread_meta_by_name_str;
|
|
pub use session_index::find_thread_name_by_id;
|
|
pub use session_index::find_thread_names_by_ids;
|
|
pub use state_db::StateDbHandle;
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|