Skip to content

Memories should semantically deduplicate repeated task learnings during consolidation #29818

Closed

Description

@ZHOUKAILIAN

What feature would you like to see?

Codex memories should consolidate repeated task-level learnings into higher-level reusable principles instead of repeatedly appending near-identical conclusions under separate tasks.

In a long-running Codex setup, ~/.codex/memories/MEMORY.md can gradually become a verbose task ledger. The detailed task history is useful, but many of the durable conclusions are semantically the same across different issues, repositories, and workflows.

For example, repeated tasks often produce principles like:

  • verify current code/logs/database state instead of relying on memory
  • do not treat an old PR/comment as proof that a bug is handled
  • separate symptom, root cause, fix, verification, and handoff state
  • keep detailed evidence in rollout summaries and keep the main memory as an index

Those are valuable learnings, but once they appear across many task groups, the memory file becomes harder to search and less useful as a retrieval source.

Current behavior

Memory consolidation appears to preserve many task-level summaries independently.

In one local setup, the main memory index had grown to roughly:

  • 2,450 lines
  • 325 KB
  • 24 task groups
  • 133 task entries
  • 166 rollout summary references

The detailed evidence is not the issue. The problem is that repeated reusable conclusions are stored many times at the task level instead of being promoted into a smaller shared principle.

This creates:

  • repeated reusable knowledge across many task groups
  • a verbose MEMORY.md
  • lower signal-to-noise during memory lookup
  • larger tool/search outputs when inspecting memory
  • more chances that old task-specific details distract from the current task

Expected behavior

Codex should distinguish between:

  1. durable principles/preferences
  2. project or workflow-specific rules
  3. task-level historical evidence
  4. detailed rollout/session artifacts

A better memory structure would:

  • keep high-frequency reusable principles once
  • merge near-duplicate conclusions across tasks
  • keep MEMORY.md as a compact index
  • keep detailed per-task evidence in rollout_summaries/
  • optionally mark task learnings as superseded by a generalized principle

Suggested implementation direction

During memory consolidation, Codex could add a semantic deduplication step:

  • cluster candidate memories by meaning, not just exact text
  • promote repeated conclusions into a shared principle
  • retain links to representative rollout summaries
  • avoid re-adding the same principle under every new task
  • expose a memory compaction/report command so users can inspect what was merged or dropped

Related issues

This is related to memory quality and consolidation, but distinct from concurrency or memory-loss bugs such as #26684. This request is about long-term semantic memory hygiene: the memory is preserved, but over time it becomes too repetitive and task-ledger-like.

Environment

  • Codex CLI: 0.142.0
  • Platform: macOS
  • Memory files involved:
    • ~/.codex/memories/MEMORY.md
    • ~/.codex/memories/memory_summary.md
    • ~/.codex/memories/rollout_summaries/

Why this matters

The current behavior preserves too much task-local narrative and not enough abstracted reusable knowledge. The result is that memory technically works, but it becomes noisy over time.

A memory system should behave more like a curated knowledge index than an append-only task diary.

Activity

  1. added
    enhancement
    CLI
    on Jun 24, 2026
  2. Johnson-dev-1808 commented on Aug 25, 2026

    @Johnson-dev-1808

    Reproduced again on 2026-08-25 after a built-in consolidation cycle.

    Environment:

    • Codex App embedded runtime: codex-cli 0.149.0-alpha.4.1
    • macOS: Darwin 25.5.0 arm64 arm
    • current upstream source checked at openai/codex@5ce04789fbbd4b12c80340a8246cfb00d0a330d5

    Observed active-memory result:

    • MEMORY.md: 1,958 words
    • memory_summary.md: 768 words
    • 11 ## Task N headings
    • 17 thread_id= annotations
    • 17 rollout_path= annotations
    • 11 Failures and how to do differently sections

    The current upstream consolidation prompt still explicitly requires # Task Group, task entries, failure-history sections, and rollout provenance annotations. That makes the task-ledger shape the prescribed output rather than only a semantic-deduplication miss. A user ad-hoc memory note can reduce volume, but cannot reliably override this system-level schema.

    Root-cause correction at the prompt-owning boundary:

    1. Keep rollout_summary as archival task evidence.
    2. Gate raw_memory to confirmed durable architecture, contracts, canonical commands, non-obvious constraints, stable repeated/permanent preferences, and current release gates.
    3. Consolidate by project plus durable topic, updating an existing topic instead of appending task history.
    4. Exclude partial/fail/uncertain, plan-only, review-only, provenance metadata, timestamps, test counts, temporary errors, debugging narration, and superseded states unless a separate durable invariant is proven.
    5. Emit no active-memory entry when no durable-value criterion passes.

    Because this repository does not accept external PRs, I prepared a tested reference implementation here:
    Johnson-dev-1808@549b003

    Verification on the current upstream base:

    • just fmt-check
    • just test -p codex-memories-write: 45/45 passed
    • cargo build -p codex-cli --bin codex
    • git diff --check origin/main...HEAD

    Could this issue be reopened until the task-shaped consolidation schema is removed from the shipped runtime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CLIenhancementmemory

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions