Add official CLI commands to inspect, prune, delete, and scope Codex memories
Problem
Codex CLI has an experimental memories feature, but I could not find an official CLI surface to inspect, prune, delete, or re-scope accumulated memory entries.
In a real Windows setup, the global memory file has already grown to thousands of lines and hundreds of KB:
- Codex CLI:
codex-cli 0.142.2 - Platform: Windows / PowerShell
codex features list:memoriesisexperimental true~/.codex/config.toml:[features] memories = true~/.codex/memories/MEMORY.md: 4,896 lines, ~601 KB~/.codex/memories/raw_memories.md: ~759 KB
The practical issue is not just file size. Project-specific memories can accumulate in the global memory registry, and there is no obvious official way for the user to remove or move those entries without manually editing internal files.
Why this matters
Without memory management commands, the memory feature can become unbounded over time:
- global
MEMORY.mdcan grow indefinitely across many repositories and sessions - project-specific context can leak into global memory and influence unrelated workspaces
- users have to manually edit generated/internal memory files to clean up stale or misplaced entries
- there is no safe dry-run, backup, or audit trail for memory deletion
- large global memory increases context noise and makes memory behavior harder to trust
Current CLI surface checked
I checked the visible CLI commands and did not find a memory-management command:
codex --helpcodex debug --helpcodex features list
codex delete appears to delete saved sessions, not memory entries.
Requested feature
Please add an official Codex CLI memory management surface, for example:
codex memory list
codex memory search <query>
codex memory show <id>
codex memory delete <id> --dry-run
codex memory delete --query <query> --dry-run
codex memory prune --older-than 90d --dry-run
codex memory prune --scope project --dry-run
codex memory move <id> --to-project <path>
codex memory compact --scope global
Useful requirements:
- stable memory entry IDs
- scope metadata: global, project, workspace path, skill, rollout/session source
- dry-run by default for destructive operations
- automatic backup before deletion/compaction
- ability to delete or move project-specific entries out of global memory
- clear distinction between deleting a saved session and deleting memory
- documentation for
~/.codex/memories/MEMORY.md,raw_memories.md,memory_summary.md, androllout_summaries/
Related issues
This is related to memory UX and explicit memory behavior, but specifically about cleanup/deletion/pruning and scoping:
- #19195
- #19758
6 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
The product boundary I would make explicit is that memory is user-owned state, not just an internal cache. If the agent can accumulate durable influence across projects, the user needs a first-class way to inspect, scope, move, prune, and delete that influence without editing generated files by hand.
I would split the CLI surface into three safe layers:
The important default is that destructive memory operations should behave like state-changing agent actions. They should show the exact entries affected, the scope being changed, the backup location, and the post-operation summary before the write is accepted. A memory delete command should not feel like deleting a saved chat session; it changes future model context and should have its own receipt.
The regression shape I would want is a fixture with one global memory, one project-scoped memory, and one stale rollout-derived memory. The CLI should prove that search finds all three, current-workspace scope explains only the applicable ones, dry-run delete changes nothing, move-to-project removes global leakage, and prune creates a restorable backup before compaction.
That would make memory useful without letting it become invisible policy.
Boundary: architecture and regression-test feedback only; no claim about running the product, validating implementation behavior, implementation correctness, roadmap fit, merge readiness, security review, production readiness, partnership, customer interest, official alignment, OpenAI usage, Codex usage, conformance certification, or Neura usage.
I pushed a read-only inspection slice for this here:
Branch: https://github.com/Nicolas0315/codex/tree/codex/memory-inspect-cli
Commits:
89b32c6302316b9c9af792e9ce04a9a639dcb9e1feat(memory): expose memory inventory entries1e7d8a8895d2d89f7e3c80caee0ec4ed2b3d9844feat(memory): add CLI inspection commandsWhat it adds:
codex memory listcodex memory search <query>codex memory show <thread-id>--jsonoutputcwd,rollout_path,git_branch,memory_modeBoundary: this intentionally handles the non-destructive inspection/audit part first. It does not add prune/delete/scope mutation commands yet.
Local verification on
rtx4090:cargo fmtpassed; stable rustfmt emitted the repo's existingimports_granularity = Itemwarningcargo check -p codex-cli -p codex-statepassedcargo test -p codex-cli --test memory -- --nocapturepassed: 2/2git diff --check HEAD~2 HEADpassedcargo nextest run -p codex-cli -p codex-state --no-fail-fast: 450/451 passed. The only failure wasdoctor::thread_inventory::tests::thread_inventory_check_warns_for_missing_stale_and_mismatched_rows; I reproduced the same failure on clean merge-based047c33a1on this Windows host, so it appears pre-existing and unrelated to this branch.SSH validation of exact HEAD
1e7d8a8895d2d89f7e3c80caee0ec4ed2b3d9844:cyberagent-mac-m5max:git diff --check,cargo check -p codex-cli -p codex-state, andcargo test -p codex-cli --test memory -- --nocapturepassednicolas2025:git diff --check,cargo check -p codex-cli -p codex-state, andcargo test -p codex-cli --test memory -- --nocapturepassednicolas-macbook-pro:git diff --checkpassed; cargo missing, compile tests skippedrtx5060ti:git diff --checkpassed; Rust build skipped due the host's known MSVC linker failureI attempted to open a PR from
Nicolas0315:codex/memory-inspect-cli, but GitHub returnedNicolas0315 does not have the correct permissions to execute CreatePullRequestfor this repo.This is the right first slice: make inspection boring, deterministic, and strictly read-only before adding any scope repair or destructive commands.
The acceptance boundary I would put around the inspection layer is that it is a projection of memory state, not a memory operation. Listing, searching, and showing entries should never hydrate new memory, rewrite scope metadata, compact stale rows, update access timestamps, or normalize anything in place. If the command changes future context, it has already crossed out of inspection.
For the first contract, I would make the JSON shape stable enough that other tooling can diff it:
The regression shape I would want before mutation commands land:
That keeps the next step clean: once inspection is a stable, side-effect-free evidence layer, scope repair and prune/delete can require a separate dry-run plus receipt boundary instead of inheriting ambiguity from the read path.
Boundary: architecture and regression-test feedback only; no claim about using this branch, running this branch, validating implementation behavior, implementation correctness, merge readiness, security review, production readiness, partnership, customer interest, official alignment, OpenAI usage, Codex usage, conformance certification, or Neura usage.
Adding a current macOS Desktop data point that may help define the remaining control-surface gap.
Environment: Codex Desktop 26.715.52143 with bundled codex-cli 0.145.0-alpha.18.
A privacy-scrubbed local audit found roughly 2.8 MB in the native-memory storage tree, including hundreds of KB of consolidated and raw memory, two dozen pending notes, and more than 100 rollout summaries. The retained corpus mixed cross-project material with stale operational state and stale paths.
The current app-server schema exposes memory/reset. In this build, it behaved as an all-or-nothing operation: it cleared the memory directories and corresponding database rows. I could not find a supported selective-delete, manual-consolidate, or in-place rebuild control.
A controlled cleanup/disable check also clarified an important distinction:
With features.memories=true, use_memories=false, generate_memories=false, and disable_on_external_context=true, an existing corpus could remain on disk. Its presence alone does not establish that new memories were generated while those settings were false.
After memory/reset, setting features.memories=false while retaining the other false values resulted in no observed native-memory injection or corpus/database regrowth across multiple fresh Tasks in different working directories after ordinary read-only activity.
Project AGENTS.md instructions still loaded normally, so disabling native memory did not disable static project instructions.
This supports an official surface for inspection, selective deletion, pruning, and controlled rebuild, plus clearer semantics distinguishing “stop using,” “stop generating,” and “erase existing corpus.” The current reset is a useful recovery primitive, but it is too coarse for correcting one stale or mis-scoped memory.
The native Codex memory store still needs the official management surface proposed here. For users who need a user-controlled layer now, GoodMemory 0.7.1 can run alongside Codex without modifying the native
~/.codex/memoriescorpus:Its installed MCP surface is read-only by default and exposes
goodmemory_inspect_memory,goodmemory_trace_recall,goodmemory_search_index,goodmemory_get_records, andgoodmemory_stats. Durable records have stable IDs, explicit user/workspace/agent scope and provenance; a targeted record can be removed with:This is deliberately a parallel workaround/reference implementation, not a way to inspect, prune, or repair Codex native memory. The useful product boundary is that read-only inspection stays side-effect-free, while a destructive operation is explicit and ID-scoped.
Disclosure: I maintain GoodMemory. No claim that it replaces Codex native memory or fixes this issue.