Reuse MCP tool snapshot within a sampling request#31292
Merged
Conversation
a8751a9 to
a1a0d9d
Compare
pakrym-oai
reviewed
Jul 7, 2026
| } | ||
| } | ||
|
|
||
| pub(crate) async fn mcp_tools(&self) -> &[ToolInfo] { |
Collaborator
There was a problem hiding this comment.
If this field is purely computable based on McpRuntimeSnapshot it should stay on McpRuntimeSnapshot and be invalidated when it is changed.
pakrym-oai
requested changes
Jul 7, 2026
pakrym-oai
approved these changes
Jul 8, 2026
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.
Follow-up to #30226.
Why
#30226 makes Apps World State inspect the MCP tool list, while tool-router construction reads the same list again later in the sampling request.
list_all_tools()walks the MCP clients and may reconnect or wait for tools, so doing that work twice adds latency and lets context and tool construction observe different MCP states for one request.What
StepContext.StepContextrefresh naturally for the next sampling request, without manager-level caching or invalidation.Testing
just test -p codex-core apps_instructionsjust test -p codex-core apps_guidance_appears_after_background_recovery_within_a_turn