Avoid duplicate codex_apps tool refresh on force refetch#22196
Open
mzeng-openai wants to merge 1 commit into
Open
Avoid duplicate codex_apps tool refresh on force refetch#22196mzeng-openai wants to merge 1 commit into
mzeng-openai wants to merge 1 commit into
Conversation
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Why
app/list(force_refetch = true)creates a fresh temporaryMcpConnectionManagerso it can read currentcodex_appstools. That fresh manager already performs an uncachedtools/listduring startup and writes the result into the Codex Apps tools cache.The old force-refetch branch then immediately called
hard_refresh_codex_apps_tools_cache()on that same fresh manager, which issued a second uncachedtools/listagainst the same server connection before any caller could observe the first result. That duplicated a live inventory request without making the data any fresher.This is separate from the repeated in-process inventory reads that can happen during normal
codex execstartup. Those reads reuse the already-loaded tool snapshot; the redundant network call was specific to the fresh-manager force-refetch flow.Relevant code:
list_accessible_connectors_from_mcp_tools_with_environment_managerWhat changed
force_refetch, wait for the freshly-created temporary manager'scodex_appsstartup to complete, then reuselist_all_tools()from that manager instead of forcing a second live refresh.codex_appsis not ready: continue with the startup/cached tools path rather than changing visible behavior.tools/listcalls and assert:Regression coverage:
list_apps_force_refetch_patches_updates_from_cached_snapshotsVerification
cargo test -p codex-app-server list_apps_force_refetch_patches_updates_from_cached_snapshotscargo test -p codex-core connectorsjust fix -p codex-core