mirror of
https://github.com/pchuan98/codex.git
synced 2026-07-01 00:31:56 +08:00
1acb722e8a
## Why Work(TPP) threads can be launched from the Desktop app, but if they all keep the Desktop app's default originator then downstream attribution cannot distinguish local Work launches from cloud-backed Work launches. `thread/start.serviceName` already carries that launch signal, while `SessionMeta.originator` is the durable thread-level value that survives resume and fork. This change converts the Desktop Work service names into an effective originator at thread creation time, persists that originator with the thread, and keeps using it for later model requests and memory writes. ## What changed - Map `CODEX_WORK_LOCAL` and `CODEX_WORK_CLOUD` service names to per-thread originators, while preserving `CODEX_INTERNAL_ORIGINATOR_OVERRIDE` as the highest-precedence override. - Persist the effective originator in `SessionMeta.originator`, read it back on resume/fork, and inherit the parent originator for subagent spawns when there is no persisted session metadata. - Handle truncated `SpawnAgentForkMode::LastNTurns` forks by falling back to the live parent originator when the forked history no longer includes `SessionMeta`. - Thread the per-thread originator through Responses headers, websocket/compaction request paths, thread-store creation, rollout metadata, and memory stage-one telemetry. ## Verification - `just test -p codex-core agent::control::tests::spawn_thread_subagent_inherits_parent_originator_without_fork agent::control::tests::spawn_thread_subagent_fork_last_n_turns_inherits_parent_originator_without_session_meta thread_manager::tests::originator_override_precedes_service_name_remapping` - `just test -p codex-core agent::control::tests::resume_thread_subagent_restores_stored_metadata_and_effective_multi_agent_mode` - `just test -p codex-memories-write` - `just fix -p codex-core -p codex-memories-write` - `git diff --check`
82 lines
2.8 KiB
Rust
82 lines
2.8 KiB
Rust
//! Rollout persistence and discovery for Codex session files.
|
|
|
|
use std::sync::LazyLock;
|
|
|
|
use codex_protocol::protocol::SessionSource;
|
|
|
|
pub(crate) mod compression;
|
|
pub(crate) mod config;
|
|
pub(crate) mod list;
|
|
pub(crate) mod metadata;
|
|
mod persistence_metrics;
|
|
pub(crate) mod policy;
|
|
pub(crate) mod recorder;
|
|
pub(crate) mod search;
|
|
pub(crate) mod session_index;
|
|
mod sqlite_metrics;
|
|
pub mod state_db;
|
|
|
|
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 compression::RolloutLineReader;
|
|
pub use compression::existing_rollout_path;
|
|
pub use compression::open_rollout_line_reader;
|
|
pub use compression::plain_rollout_path;
|
|
pub use compression::spawn_rollout_compression_worker;
|
|
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 persistence_metrics::RolloutPersistenceBatchMeasurement;
|
|
pub use persistence_metrics::RolloutPersistenceTelemetry;
|
|
pub use persistence_metrics::measure_and_filter_rollout_items;
|
|
pub use policy::is_persisted_rollout_item;
|
|
pub use policy::persisted_rollout_items;
|
|
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 search::first_rollout_content_match_snippet;
|
|
pub use search::search_rollout_matches;
|
|
pub use search::search_rollout_paths;
|
|
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 session_index::remove_thread_name_entries;
|
|
pub use state_db::StateDbHandle;
|
|
pub use state_db::sqlite_telemetry_recorder;
|
|
|
|
#[cfg(test)]
|
|
mod tests;
|