mirror of
https://github.com/openai/codex.git
synced 2026-11-18 22:20:48 +00:00
- Split the feature system into a new `codex-features` crate. - Cut `codex-core` and workspace consumers over to the new config and warning APIs. Co-authored-by: Ahmed Ibrahim <219906144+aibrahim-oai@users.noreply.github.com> Co-authored-by: Codex <noreply@openai.com>
45 lines
1.2 KiB
Rust
45 lines
1.2 KiB
Rust
use crate::codex::Session;
|
|
use crate::config::Config;
|
|
use crate::memories::phase1;
|
|
use crate::memories::phase2;
|
|
use codex_features::Feature;
|
|
use codex_protocol::protocol::SessionSource;
|
|
use std::sync::Arc;
|
|
use tracing::warn;
|
|
|
|
/// Starts the asynchronous startup memory pipeline for an eligible root session.
|
|
///
|
|
/// The pipeline is skipped for ephemeral sessions, disabled feature flags, and
|
|
/// subagent sessions.
|
|
pub(crate) fn start_memories_startup_task(
|
|
session: &Arc<Session>,
|
|
config: Arc<Config>,
|
|
source: &SessionSource,
|
|
) {
|
|
if config.ephemeral
|
|
|| !config.features.enabled(Feature::MemoryTool)
|
|
|| matches!(source, SessionSource::SubAgent(_))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if session.services.state_db.is_none() {
|
|
warn!("state db unavailable for memories startup pipeline; skipping");
|
|
return;
|
|
}
|
|
|
|
let weak_session = Arc::downgrade(session);
|
|
tokio::spawn(async move {
|
|
let Some(session) = weak_session.upgrade() else {
|
|
return;
|
|
};
|
|
|
|
// Clean memories to make preserve DB size
|
|
phase1::prune(&session, &config).await;
|
|
// Run phase 1.
|
|
phase1::run(&session, &config).await;
|
|
// Run phase 2.
|
|
phase2::run(&session, config).await;
|
|
});
|
|
}
|