feat(core, mcp): cache codex_apps tools in memory - #29003
Merged
Conversation
owenlin0
force-pushed
the
owen/cache_codex_apps_tools_in_mem
branch
from
June 22, 2026 15:31
7c52039 to
85996d1
Compare
owenlin0
marked this pull request as ready for review
June 22, 2026 15:47
Contributor
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 85996d140d
ℹ️ 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".
owenlin0
force-pushed
the
owen/cache_codex_apps_tools_in_mem
branch
from
June 22, 2026 17:47
2cb705f to
c613db7
Compare
owenlin0
force-pushed
the
owen/cache_codex_apps_tools_in_mem
branch
from
June 23, 2026 21:58
c613db7 to
d1acfbe
Compare
mzeng-openai
approved these changes
Jun 24, 2026
owenlin0
force-pushed
the
owen/cache_codex_apps_tools_in_mem
branch
from
June 24, 2026 16:06
e3e9a72 to
e6b16cf
Compare
owenlin0
added a commit
that referenced
this pull request
Jun 24, 2026
aibrahim-oai
approved these changes
Jun 25, 2026
owenlin0
force-pushed
the
owen/cache_codex_apps_tools_in_mem
branch
from
June 25, 2026 20:41
0c8e68b to
4083532
Compare
owenlin0
enabled auto-merge (squash)
June 25, 2026 20:48
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This makes Codex Apps tool reads use a shared in-memory snapshot instead of rereading the disk cache every time
list_all_tools()runs. Disk still seeds the cache on startup and gets updated after successful fetches, but it is no longer the live read path.The core change is that
McpManagernow owns a process-scopedCodexAppsToolsCache. Codex threads in the same app-server process now share this Codex Apps in-memory tools snapshot. The snapshot is keyed by the Codex home plus the Codex Apps identity: the active Codex auth user/workspace and the effective Codex Apps MCP source config.There's already code to hard-refresh the cache, so we respect it in this PR.
Local benchmark
I ran a local steady-state microbenchmark of the exact repeated Codex Apps cached-tools read this PR removes, using the same real local cache payload in both trees:
3,678,138bytes and381tools. The cache file was already warm in the OS page cache, so this measures same-process reread/deserialization work rather than cold-disk latency or full turn latency. Each run is 25 iterations (mimicking a turn that makes 25 inference calls).origin/maindisk read + JSON deserialize +filter_tools50.755 ms52.894 ms51.825 mscurrent_tools+filter_tools0.740 ms0.778 ms0.759 msThat removes about
51 msfrom each repeated Codex Apps cached-tools read on this machine, roughly68xfaster for that subpath. It is useful evidence for the hot path this PR changes, but not a claim that every production turn gets51 msfaster; end-to-end impact also depends on the rest oflist_all_tools()and tool-payload construction.This is on my M2 Max macbook, so with a slower disk this would be much worse (and indeed we did see this really blew up turn runtime with a slow disk).