Repository navigation
Defer MCP imports for agents without MCP tools - #6216
Closed
markstuart-oai wants to merge 1 commit into
Closed
markstuart-oai wants to merge 1 commit into
markstuart-oai wants to merge 1 commit into
Conversation
markstuart-oai
requested review from
a team,
rm-openai and
seratch
as code owners
November 25, 2026 00:59
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
3 tasks done
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.
Summary
This pull request has been shortening cold starts for agents without MCP tools. Importing
Agenthas been loading the Model Context Protocol (MCP) package throughagents.mcp.util, even for local function tools.With this change, the SDK has been loading the compatibility helpers on demand during MCP tool conversion, invocation or custom data extraction. One tradeoff for MCP users — a potential pause on the event loop at first use.
Benchmarks
Startup. From launch to the first checked answer with a local tool, the PR has been saving a median 179 ms per pair (95% interval 137–243 ms), or 15.9%. Peak process memory has been falling by 19.2 MiB.
MCPServerimported at launch on both sides, a smaller 4.6% saving [4.2%, 5.8%].MCPServerStdioimported immediately after the ordinary SDK imports, 225 ms more for that step. No clear change in total import time across 16 separate pairs.Tradeoffs. Two typed tool-output workloads have been exceeding the 3% margin on both runs. Both have been following large integer-list outputs in the same process. Results from 64 fresh pairs below.
Garbage collection. Three separate traces per version. A full collection on the first typed stream in 3/3 PR processes and 0/3 on main. In a separate 20-block test, releasing completed stream results has been moving that pause to a later call. Individual requests have still been incurring it.
SQLite. The large write has been taking 4.64% longer [1.55%, 7.40%] on repeat. Uncertain against the 3% margin.
Empty server. Same timed code and output checks. After timing, the harness has been checking for MCP on main and its absence on this PR. The separate
MCPServercheck above has been requiring the import on both sides.All 83 comparisons with Codex off. Offline Python SDK workloads on one Linux host with CPython 3.12.16. Each comparison has been measuring this change alone against
mainat4e162c79, without network or model latency.Timings and 95% intervals for all 83 comparisons
Test plan and checks
.agents/skills/code-change-verification/scripts/run.sh) including formatting, lint, mypy, Pyright and both pytest phases. 12,865 passed, 30 skipped.Credential-redaction tests have been matching the fixture username
userin the original checkout path. All 136 tests in the two affected files and the full suite have been passing from a neutral path with identical source and assertions.