feat: house-keeping memories 2 (#20000)

Just move metrics in a dedicated file
This commit is contained in:
jif-oai
2026-04-28 17:26:44 +02:00
committed by GitHub
Unverified
parent 5a79dfab7c
commit 21e19912e0
5 changed files with 21 additions and 10 deletions
+1
View File
@@ -7,6 +7,7 @@
mod control;
mod extensions;
mod guard;
mod metrics;
mod phase1;
mod phase2;
mod prompts;
+11
View File
@@ -0,0 +1,11 @@
pub(crate) const MEMORY_STARTUP: &str = "codex.memory.startup";
pub(crate) const MEMORY_PHASE_ONE_JOBS: &str = "codex.memory.phase1";
pub(crate) const MEMORY_PHASE_ONE_E2E_MS: &str = "codex.memory.phase1.e2e_ms";
pub(crate) const MEMORY_PHASE_ONE_OUTPUT: &str = "codex.memory.phase1.output";
pub(crate) const MEMORY_PHASE_ONE_TOKEN_USAGE: &str = "codex.memory.phase1.token_usage";
pub(crate) const MEMORY_PHASE_TWO_JOBS: &str = "codex.memory.phase2";
pub(crate) const MEMORY_PHASE_TWO_E2E_MS: &str = "codex.memory.phase2.e2e_ms";
pub(crate) const MEMORY_PHASE_TWO_INPUT: &str = "codex.memory.phase2.input";
pub(crate) const MEMORY_PHASE_TWO_TOKEN_USAGE: &str = "codex.memory.phase2.token_usage";
+4 -4
View File
@@ -1,5 +1,9 @@
use crate::STAGE_ONE_PROMPT;
use crate::build_stage_one_input_message;
use crate::metrics::MEMORY_PHASE_ONE_E2E_MS;
use crate::metrics::MEMORY_PHASE_ONE_JOBS;
use crate::metrics::MEMORY_PHASE_ONE_OUTPUT;
use crate::metrics::MEMORY_PHASE_ONE_TOKEN_USAGE;
use crate::runtime::MemoryStartupContext;
use crate::runtime::StageOneRequestContext;
use codex_config::types::MemoriesConfig;
@@ -32,10 +36,6 @@ const JOB_LEASE_SECONDS: i64 = 3_600;
const JOB_RETRY_DELAY_SECONDS: i64 = 3_600;
const THREAD_SCAN_LIMIT: usize = 5_000;
const PRUNE_BATCH_SIZE: usize = 200;
const MEMORY_PHASE_ONE_JOBS: &str = "codex.memory.phase1";
const MEMORY_PHASE_ONE_E2E_MS: &str = "codex.memory.phase1.e2e_ms";
const MEMORY_PHASE_ONE_OUTPUT: &str = "codex.memory.phase1.output";
const MEMORY_PHASE_ONE_TOKEN_USAGE: &str = "codex.memory.phase1.token_usage";
struct JobResult {
outcome: JobOutcome,
+4 -4
View File
@@ -1,5 +1,9 @@
use crate::build_consolidation_prompt;
use crate::memory_root;
use crate::metrics::MEMORY_PHASE_TWO_E2E_MS;
use crate::metrics::MEMORY_PHASE_TWO_INPUT;
use crate::metrics::MEMORY_PHASE_TWO_JOBS;
use crate::metrics::MEMORY_PHASE_TWO_TOKEN_USAGE;
use crate::prune_old_extension_resources;
use crate::rebuild_raw_memories_file_from_memories;
use crate::runtime::MemoryStartupContext;
@@ -30,10 +34,6 @@ const REASONING_EFFORT: codex_protocol::openai_models::ReasoningEffort =
const JOB_LEASE_SECONDS: i64 = 3_600;
const JOB_RETRY_DELAY_SECONDS: i64 = 3_600;
const JOB_HEARTBEAT_SECONDS: u64 = 90;
const MEMORY_PHASE_TWO_JOBS: &str = "codex.memory.phase2";
const MEMORY_PHASE_TWO_E2E_MS: &str = "codex.memory.phase2.e2e_ms";
const MEMORY_PHASE_TWO_INPUT: &str = "codex.memory.phase2.input";
const MEMORY_PHASE_TWO_TOKEN_USAGE: &str = "codex.memory.phase2.token_usage";
#[derive(Debug, Clone, Default)]
struct Claim {
+1 -2
View File
@@ -1,4 +1,5 @@
use crate::guard;
use crate::metrics::MEMORY_STARTUP;
use crate::phase1;
use crate::phase2;
use crate::runtime::MemoryStartupContext;
@@ -12,8 +13,6 @@ use codex_protocol::protocol::SessionSource;
use std::sync::Arc;
use tracing::warn;
const MEMORY_STARTUP: &str = "codex.memory.startup";
/// Starts the asynchronous startup memory pipeline for an eligible root session.
///
/// The pipeline is skipped for ephemeral sessions, disabled feature flags, and