Repository navigation
Studio: remember MCP servers per project - #18290
Conversation
The project edit dialog now lists the account's MCP servers. The smoke's
catch-all /api route answered that request with {}, so the dialog's
rows.filter threw and the scene's page-error check failed. Return an array
like the real endpoint and check the new MCP section in the edit dialog.
## Summary Two gloo tests started failing in the CPU tensor-parallel shards on several unrelated PRs (#18290, #17550): ``` tests/test_tp_kv_replicated_gloo.py::test_kv_heads_below_tp_are_replicated_per_rank E assert (0, 16) == (0, 128) tests/test_tp_native_gloo.py::test_tp2_tied_norm_weight_is_summed_once E Max absolute difference: 7.361173629760742e-06 (tolerance 3.4e-06) ``` On a host with a cold Hugging Face cache, both fail every time, including on commits from before any recent tensor-parallel change. ## Cause Not a code change. The gloo tensor and pipeline parallel builders (`build()` in `tests/test_tp_native_oracle.py` and `tests/test_pp_native_gloo.py`) read a tiny Hub repo's `config.json` at its latest revision and build random weights from it. `trl-internal-testing/tiny-Qwen3ForCausalLM` was re-uploaded upstream on 2026-11-19 (commit `92ee0a3c80`), and its config changed `head_dim` from 128 to 16: | revision | hidden_size | heads / KV heads | head_dim | |---|---|---|---| | `25bb9b8963` (previous) | 8 | 4 / 2 | 128 | | `92ee0a3c80` (current) | 8 | 4 / 2 | 16 | - `test_kv_heads_below_tp_are_replicated_per_rank` hardcoded 128 for the expected per-rank KV row slice. - `test_tp2_tied_norm_weight_is_summed_once` compares parity values that the new shapes move just past their tolerance. Runners that still have the old config cached pass and fresh fetches fail. That is why the same base, with the same package versions (transformers 5.18.0, torch 2.10.0), was green on some PRs and red on others. `trl-internal-testing/tiny-Qwen3MoeForCausalLM` was re-uploaded the same day. The tensor-parallel code is correct. It slices by the config's `head_dim`. ## Fix Test-only: - `tests/_tiny_fixture_revisions.py` pins a full commit id for every tiny repo the two builders use: - Qwen3 and Qwen3-MoE at the revision before the re-upload; - the rest at their current revision, the one CI has been green on. - Both builders load the config with `AutoConfig.from_pretrained(repo, revision = revision(repo))`. Moving a fixture is now a deliberate edit to the pin table. - `tests/test_tiny_fixture_revisions_pinned.py` fails if either builder module names a tiny repo without a pin, if a pin is not a full commit id, or if a builder stops loading at the pin. - `test_kv_heads_below_tp_are_replicated_per_rank` also pins `head_dim` in its own overrides and derives the expected rows from it, so it states the shape it checks. ## Verification | | result | |---|---| | `test_tp_kv_replicated_gloo.py`, main | 1 failed, 10 passed | | `test_tp_kv_replicated_gloo.py`, this branch | 11 passed | | `test_tp_native_gloo.py` (`tied_norm`), main | 1 failed | | `test_tp_native_gloo.py`, this branch | 57 passed | | `test_pp_native_gloo.py`, this branch | 24 passed | | `test_tiny_fixture_revisions_pinned.py` | 3 passed | | `tp_native.py` sabotaged to give every rank KV head 0 | the KV test fails on ranks 2 and 3 (`(0, 16)`) | So the per-rank KV head check still catches wrong slicing. ruff is clean.
|
@danielhanchen could you take a look when you have a moment? This lets each Studio project keep its own MCP server selection (#17970). The three red checks don't come from this change:
Could you rerun the frontend job? |
…ect-mcp # Conflicts: # studio/backend/core/inference/tools.py
|
Could a maintainer rerun these two jobs? Both were cancelled at their time limits:
After merging current |
|
@codex review |
1 similar comment
|
@codex review |
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8973b8c462
ℹ️ 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".
| INSERT INTO chat_projects | ||
| (id, name, instructions, root_path, archived, created_at, updated_at) | ||
| VALUES (?, ?, ?, ?, ?, ?, ?) | ||
| (id, name, instructions, mcp_server_ids, root_path, archived, created_at, updated_at) |
There was a problem hiding this comment.
Persist supplied MCP selections on upsert conflicts
When POST /api/chat/projects saves an existing project ID, mcp_server_ids is included in the insert but omitted from the ON CONFLICT(id) DO UPDATE SET clause. Reposting a project with another subset, [], or null therefore succeeds while retaining its previous MCP selection, even though fields such as its name update normally. Handle explicitly supplied MCP preferences in the conflict branch too, while preserving existing preferences for callers that omit the field.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
POST /api/chat/projects is the create path: the dialog creates new IDs, backup restore skips IDs that already exist, and every edit (including the MCP selection) goes through PATCH. No Studio caller reposts an existing project with a selection.
|
Codex Review: Didn't find any major issues. Keep them coming! 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". |
|
@codex review |
1 similar comment
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9c78c80677
ℹ️ 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".
| if mcp_project_excludes(server_id, session_id): | ||
| return f"Error: MCP server '{display}' is not enabled for this project" |
There was a problem hiding this comment.
Propagate project scope to Deep Research MCP calls
When a project excludes a globally enabled server that is already configured as a Deep Research MCP source, research launched from that project's chats still sends queries to it. core/research_runs.py:_research() discovers tools without setting the project scope (lines 2415–2417), and _search_mcp_tools() calls execute_mcp_tool() without session_id (lines 1343–1349), so this new execution check receives None and does not exclude the server. Resolve the run thread's project for both discovery and execution so that empty selections and subsets also apply to research calls.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Deep Research sources are picked explicitly per run (the run config's mcpSources lists the exact server and tool pairs the user chose in the research setup). The project setting scopes the chat model's MCP catalog, as the dialog says (applies when MCP is on in a chat); overriding a source the user hand-picked for this research would silently drop it. Global disable still applies to research calls.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Chef's kiss. 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". |
Summary
Related to #17970
Verification
Screenshots
Edit project before and after this PR, on a project with two enabled MCP servers. After saving only Docs server and reopening the dialog, Docs server stays selected and the project's saved
mcpServerIdsholds that one id.