Skip to content

Stabilize memory Phase 2 input ordering#19967

Merged
jif-oai merged 2 commits intomainfrom
jif/memories-stable-order
Apr 28, 2026
Merged

Stabilize memory Phase 2 input ordering#19967
jif-oai merged 2 commits intomainfrom
jif/memories-stable-order

Conversation

@jif-oai
Copy link
Copy Markdown
Collaborator

@jif-oai jif-oai commented Apr 28, 2026

Why

Phase 2 still needs to choose the most relevant stage-1 memory outputs by usage and recency, but exposing that ranking as the rendered raw_memories.md order creates unnecessary large diff. Usage-count or timestamp changes can reshuffle otherwise unchanged memories, making the workspace diff noisy and giving the consolidation prompt a misleading recency signal from file position.
This fix will reduce token consumption

What Changed

  • Keep the existing top-N Phase 2 selection ranking by usage_count, last_usage, source_updated_at, and thread_id.
  • Return the selected rows in stable ascending thread_id order before syncing Phase 2 filesystem inputs.
  • Update the memory README, raw memories header, and consolidation prompt so they describe the stable order and tell the prompt to use metadata and workspace diffs instead of file order as the recency signal.
  • Adjust the memory runtime tests to use deterministic thread IDs and assert the stable return order separately from the ranked selection semantics.

Test Coverage

  • Existing memory runtime tests in codex-rs/state/src/runtime/memories.rs now cover the stable returned ordering for Phase 2 inputs.

@jif-oai
Copy link
Copy Markdown
Collaborator Author

jif-oai commented Apr 28, 2026

@codex review

@jif-oai jif-oai changed the title feat: memories stable ordering Stabilize memory Phase 2 input ordering Apr 28, 2026
@chatgpt-codex-connector
Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Already looking forward to the next diff.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Co-authored-by: Codex <noreply@openai.com>
@jif-oai jif-oai requested a review from a team as a code owner April 28, 2026 11:23
@jif-oai jif-oai merged commit fa127be into main Apr 28, 2026
25 checks passed
@jif-oai jif-oai deleted the jif/memories-stable-order branch April 28, 2026 11:32
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 28, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants