Repository navigation
Studio backend tests: close a scoped MCP session a test leaves cached - #15407
Merged
Merged
Conversation
Member
Author
|
@codex review |
Codex Review SummaryThis 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. |
|
Codex Review: Didn't find any major issues. Keep it up! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
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.
Problem
(Python 3.13, g-r)failed on #15384 (job 121698439734), which only touches FSDP2 code:The test asserts
mcp_client._mcp_sessions == {}after two unscoped calls. Whether it passes depends on what ran before it on the same xdist worker.Cause
test_mcp_http_read_timeout.py::test_tool_call_outlives_sdk_read_timeout[chat-1]makes a scoped call, which caches a session in_mcp_sessions, and never closes it. I found it by checking_mcp_sessionsafter each of the 41 backend test files that touch the MCP client. It was the only test that left an entry behind (('http://127.0.0.1:.../mcp', (), 'chat-1', 'owner')).The same pattern as #15287 (cached tools and probe cool-offs leaking between tests): module state one test leaves behind decides a later test.
Reproduced on main by running the two in that order:
Fix
test_tool_call_outlives_sdk_read_timeoutcloses its sessions in afinally._forget_mcp_discovery_statefixture instudio/backend/tests/conftest.py, from Studio backend tests: forget MCP discovery state between tests #15287, also closes any session left in_mcp_sessions, before and after each test (close_mcp_sessions(all_accounts = True))._mcp_sessionswithSimpleNamespaceobjects (test_account_tool_isolation.py) have noclose(), and their own monkeypatch restores the real dict, so thatAttributeErroris skipped.test_mcp_session_cache_reset_between_tests.py, an ordered pair in one xdist group. The first test leaves a session cached the way a scoped call does. The second fails unless the cache is empty and that session was closed.Verification
-n 2 --dist loadgroup.-n 8.test_blender_managed.pyis left out because it fails on this host on main too.