From 76de99ff25fcb927571e918dc13861b46cb63d4b Mon Sep 17 00:00:00 2001 From: Kevin Liu Date: Thu, 9 Apr 2026 10:45:02 -0700 Subject: [PATCH] [codex] add memory extensions (#16276) # External (non-OpenAI) Pull Request Requirements Before opening this Pull Request, please read the dedicated "Contributing" markdown file or your PR may be closed: https://github.com/openai/codex/blob/main/docs/contributing.md If your PR conforms to our contribution guidelines, replace this text with a detailed and high quality description of your changes. Include a link to a bug report or enhancement request. --- codex-rs/core/src/memories/mod.rs | 5 ++ codex-rs/core/src/memories/prompts.rs | 81 +++++++++++++++++-- codex-rs/core/src/memories/prompts_tests.rs | 48 ++++++++++- .../core/templates/memories/consolidation.md | 4 +- 4 files changed, 128 insertions(+), 10 deletions(-) diff --git a/codex-rs/core/src/memories/mod.rs b/codex-rs/core/src/memories/mod.rs index ac49c640c..194c27c90 100644 --- a/codex-rs/core/src/memories/mod.rs +++ b/codex-rs/core/src/memories/mod.rs @@ -25,6 +25,7 @@ pub(crate) use control::clear_memory_root_contents; pub(crate) use start::start_memories_startup_task; mod artifacts { + pub(super) const EXTENSIONS_SUBDIR: &str = "memories_extensions"; pub(super) const ROLLOUT_SUMMARIES_SUBDIR: &str = "rollout_summaries"; pub(super) const RAW_MEMORIES_FILENAME: &str = "raw_memories.md"; } @@ -106,6 +107,10 @@ fn rollout_summaries_dir(root: &Path) -> PathBuf { root.join(artifacts::ROLLOUT_SUMMARIES_SUBDIR) } +fn memory_extensions_root(root: &Path) -> PathBuf { + root.with_file_name(artifacts::EXTENSIONS_SUBDIR) +} + fn raw_memories_file(root: &Path) -> PathBuf { root.join(artifacts::RAW_MEMORIES_FILENAME) } diff --git a/codex-rs/core/src/memories/prompts.rs b/codex-rs/core/src/memories/prompts.rs index 56cb2b7b6..079ccd5c6 100644 --- a/codex-rs/core/src/memories/prompts.rs +++ b/codex-rs/core/src/memories/prompts.rs @@ -1,3 +1,4 @@ +use crate::memories::memory_extensions_root; use crate::memories::memory_root; use crate::memories::phase_one; use crate::memories::storage::rollout_summary_file_stem_from_parts; @@ -31,6 +32,18 @@ static MEMORY_TOOL_DEVELOPER_INSTRUCTIONS_TEMPLATE: LazyLock