mirror of
https://github.com/openai/codex.git
synced 2026-10-21 17:48:44 +00:00
## Summary - rename the core codex module root to session/mod.rs without using #[path] - move the codex module directory and tests under core/src/session - remove session/mod.rs reexports so call sites use explicit child module paths ## Testing - cargo test -p codex-core --lib - cargo check -p codex-core --tests - just fmt - just fix -p codex-core - git diff --check
45 lines
1.3 KiB
Rust
45 lines
1.3 KiB
Rust
use crate::config::Config;
|
|
use crate::memories::phase1;
|
|
use crate::memories::phase2;
|
|
use crate::session::session::Session;
|
|
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;
|
|
});
|
|
}
|