Skip to content

Wire up memory extensions for ACP sessions#329

Closed
jixianyihao wants to merge 1 commit into
zed-industries:mainfrom
jixianyihao:codex/issue-327-memory-extensions
Closed

Wire up memory extensions for ACP sessions#329
jixianyihao wants to merge 1 commit into
zed-industries:mainfrom
jixianyihao:codex/issue-327-memory-extensions

Conversation

@jixianyihao

@jixianyihao jixianyihao commented Jun 18, 2026

Copy link
Copy Markdown

Summary

  • install the Codex memories extension in the ACP extension registry
  • trigger the memories startup pipeline after an ACP prompt is submitted
  • identify ACP sessions as SessionSource::Mcp and keep them visible in session listing
  • add coverage for extension registry wiring, memory summary injection, session source selection, and startup hook dispatch

Addresses the ACP-side wiring in #327.

ACP scenario covered

  1. An ACP client such as Zed starts codex-acp over stdio JSON-RPC.
  2. The client sends initialize, session/new, and then session/prompt for a workspace.
  3. The ACP thread is recorded as source=mcp, the memories startup task is invoked after prompt submission, and the session remains listable through the ACP session list path.
  4. The memories extension registry is installed, so memory summary context and memory tools can be contributed through the same extension path as other Codex surfaces.

Scope note

This PR no longer vendors codex-rollout. The current upstream rust-v0.137.0 codex_rollout::INTERACTIVE_SESSION_SOURCES list does not include SessionSource::Mcp, so startup extraction allowlist support for MCP-sourced rollouts should be handled in the upstream Codex dependency rather than patched in this repository.

Local verification

  • Real ACP smoke test: started target/debug/codex-acp, sent initialize -> session/new -> session/prompt -> session/close, and observed stopReason=end_turn.
  • The resulting thread was persisted in ~/.codex/state_5.sqlite with source=mcp, memory_mode=enabled, and the codex-acp workspace cwd.
  • The generated rollout had session_meta.source=mcp. Its raw memory_mode was absent, which is expected; rollout reconciliation normalizes absent memory mode to enabled in the state DB.
  • cargo tree -i codex-rollout resolves codex-rollout from the upstream git dependency, not a vendored path.

Tests

  • cargo fmt --check
  • git diff --check
  • cargo test --lib codex_agent::tests::
  • cargo test

@jixianyihao

Copy link
Copy Markdown
Author

Hi @benbrandt, could you take a look when you have a chance? This PR wires the Codex memories extension and startup pipeline into the ACP session path and includes focused coverage for the wiring.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3fc1d46dda

ℹ️ 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".

Comment thread src/codex_agent.rs
}

fn acp_session_source() -> SessionSource {
SessionSource::Mcp

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include ACP sessions in memory extraction sources

For ACP sessions created after this change, their rollouts are now persisted as SessionSource::Mcp, but the pinned codex-memories-write phase-1 startup path claims jobs via codex_rollout::INTERACTIVE_SESSION_SOURCES, which in rust-v0.137.0 contains only CLI, VSCode, and the atlas/chatgpt custom sources. As a result, when users work exclusively through ACP the startup task is triggered but never selects those ACP rollouts for memory extraction, so the feature cannot learn from ACP sessions until Mcp is added to the eligible source list (or ACP uses an eligible source).

Useful? React with 👍 / 👎.

@jixianyihao
jixianyihao force-pushed the codex/issue-327-memory-extensions branch 2 times, most recently from c85271b to f6d4675 Compare June 19, 2026 01:19
@jixianyihao

jixianyihao commented Jun 19, 2026

Copy link
Copy Markdown
Author

Update after local verification and follow-up cleanup:

I validated the ACP path with a real ACP JSON-RPC flow, not only unit tests. The smoke test started target/debug/codex-acp, sent initialize -> session/new -> session/prompt -> session/close, and the prompt completed with stopReason=end_turn.

The resulting thread was written to ~/.codex/state_5.sqlite with source=mcp and memory_mode=enabled, and the rollout session_meta also has source=mcp. This covers the ACP-side wiring: the memories extension registry is installed, the startup task is invoked after prompt submission, and ACP sessions are no longer recorded as unknown.

I removed the temporary vendor/codex-rollout patch from this PR. The current upstream rust-v0.137.0 codex_rollout::INTERACTIVE_SESSION_SOURCES list still does not include SessionSource::Mcp, so startup extraction allowlist support for MCP-sourced rollouts should be handled in the upstream Codex dependency instead of vendoring the crate here.

Verification run after removing the vendored patch:

  • cargo fmt --check
  • git diff --check
  • cargo test --lib codex_agent::tests::
  • cargo test
  • cargo tree -i codex-rollout confirms the upstream git dependency is used.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3f383d811d

ℹ️ 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".

Comment thread src/codex_agent.rs
@jixianyihao
jixianyihao force-pushed the codex/issue-327-memory-extensions branch from 3f383d8 to f030e56 Compare June 20, 2026 03:40
@benbrandt

Copy link
Copy Markdown
Member

Hi thanks for taking the time to dig in!
Development is moving to agentclientprotocol/codex-acp. The new adapter is built on the new Codex App Server, and we are pooling implementation and maintenance work across teams there. If this is still needed, please open a PR for that one. Thanks!

@benbrandt benbrandt closed this Jun 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants