mirror of
https://github.com/openai/codex.git
synced 2026-10-26 16:00:02 +00:00
## What changed - Add `memories.version` with `v1` as the default and `v2` as an opt-in selection. - Route memory generation, summaries, and retrieval tools through the selected version. Store `v2` artifacts in `memories_v2` and lazily create a separate SQLite database, keeping jobs and outputs isolated while sharing the thread catalog. - Preserve the initial memory version across extension config updates so summaries and retrieval tools use the same namespace. - Clear both versions on memory reset and remove thread memory from both stores on thread deletion. Recognize both artifact roots in shell usage telemetry. ## Testing Add regression coverage for version defaults and validation, independent job claims and outputs, deletion and reset across versions, and shell usage classification for both memory roots. GitOrigin-RevId: aa799bf87ab6ec10c8f5668213931e57547d080b
66 lines
2.0 KiB
Rust
66 lines
2.0 KiB
Rust
use codex_protocol::parse_command::ParsedCommand;
|
|
use codex_shell_command::parse_command::parse_shell_script;
|
|
|
|
pub use crate::metrics::MEMORIES_USAGE_METRIC;
|
|
|
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
|
pub enum MemoriesUsageKind {
|
|
MemoryMd,
|
|
MemorySummary,
|
|
RawMemories,
|
|
RolloutSummaries,
|
|
Skills,
|
|
}
|
|
|
|
impl MemoriesUsageKind {
|
|
pub fn as_tag(self) -> &'static str {
|
|
match self {
|
|
Self::MemoryMd => "memory_md",
|
|
Self::MemorySummary => "memory_summary",
|
|
Self::RawMemories => "raw_memories",
|
|
Self::RolloutSummaries => "rollout_summaries",
|
|
Self::Skills => "skills",
|
|
}
|
|
}
|
|
}
|
|
|
|
pub fn memories_usage_kinds_from_command(command: &str) -> Vec<MemoriesUsageKind> {
|
|
let commands = parse_shell_script(command);
|
|
if commands
|
|
.iter()
|
|
.any(|command| matches!(command, ParsedCommand::Unknown { .. }))
|
|
{
|
|
return Vec::new();
|
|
}
|
|
|
|
commands
|
|
.into_iter()
|
|
.filter_map(|command| match command {
|
|
ParsedCommand::Read { path, .. } => get_memory_kind(path.display().to_string()),
|
|
ParsedCommand::Search { path, .. } => path.and_then(get_memory_kind),
|
|
ParsedCommand::ListFiles { .. } | ParsedCommand::Unknown { .. } => None,
|
|
})
|
|
.collect()
|
|
}
|
|
|
|
fn get_memory_kind(path: String) -> Option<MemoriesUsageKind> {
|
|
let path = path.replace("memories_v2/", "memories/");
|
|
if path.contains("memories/MEMORY.md") {
|
|
Some(MemoriesUsageKind::MemoryMd)
|
|
} else if path.contains("memories/memory_summary.md") {
|
|
Some(MemoriesUsageKind::MemorySummary)
|
|
} else if path.contains("memories/raw_memories.md") {
|
|
Some(MemoriesUsageKind::RawMemories)
|
|
} else if path.contains("memories/rollout_summaries/") {
|
|
Some(MemoriesUsageKind::RolloutSummaries)
|
|
} else if path.contains("memories/skills/") {
|
|
Some(MemoriesUsageKind::Skills)
|
|
} else {
|
|
None
|
|
}
|
|
}
|
|
|
|
#[cfg(test)]
|
|
#[path = "usage_tests.rs"]
|
|
mod tests;
|