Repository navigation
Studio: stop hiding MCP tools that have a dot or a long name - #11051
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 19efb0366c
ℹ️ 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".
…d of dropping them
19efb03 to
695cfbd
Compare
|
@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: fbeb6b994c
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. 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". |
|
Confirmed this hits studio/backend/core/inference/tools.py, where a composed MCP name failing the OpenAI function.name regex is still dropped with only a log line while Settings keeps counting the tool, and the alias map plus raw-name resolution in approvals and the tool card look right. Will get this reviewed. |
The approval classifiers find a verb by its term boundaries, and those patterns treat only `_` and `-` as separators, because until now a name could not reach them containing anything else. Aliasing changed that: the raw name a tool is dispatched under is what gets classified, and MCP allows a dot in it. So a tool named `get_file.delete` classified as ordinary work while `get_file_delete` prompted, and `read_file.secret` disclosed credentials without asking. In auto mode both ran with no approval prompt. These are exactly the names that used to be dropped and now ship, so the gap arrived with them. Fold every separator to `_` where the raw name enters each classifier, rather than teaching a dozen patterns about dots. A verb behind a `.`, a `/` or a space is now its own term, and camelCase keeps its existing split. This also stops a spurious prompt: `catalog.get-catalog-entity` used to fail closed as high risk because the dot hid its `get` from the known-verb check.
Two places still showed an alias where the tool's own name belongs. `execute_tool` reported a missing server as `MCP server for tool 'catalog_get-catalog-entity_b9d734f2' not found`, because it resolved the raw name only after that check. Resolve first, so the error names the tool the user knows. A tool whose alias slot was already taken by another tool's real name was logged as a duplicate, which it is not, and the log is the only evidence that a tool went missing. Give it its own message and leave the duplicate warning to actual duplicates.
The stem an alias keeps was truncated at `55 - len(prefix)`, where 55 was the 64-character `function.name` limit with the alias suffix already subtracted by hand. Name both, so the arithmetic says what it is and the two move together. A prefix longer than the budget now yields an empty stem instead of a negative slice that would silently truncate from the wrong end. Also document why an aliased tool repeats its raw name in its description, and why valid names claim their spelling before any alias is minted.
|
Reviewed and pushed four follow-up commits. The approach here is right: aliasing the names instead of dropping them, and resolving back to the raw name at dispatch, approval and display. I traced every consumer of an One of the four is a behaviour fix, the rest are small.
Those are exactly the names that used to be dropped and now ship, so in auto mode a destructive call and a credential read would have run with no approval prompt. Fixed by folding every separator to
Every added test was mutation-checked: reverting the change it covers fails that test and no other. 2809 backend and 102 frontend tests pass locally, Both open review threads were verified as real, confirmed fixed, and resolved. On the stale-alias one I left a note: dropping the retired alias moves the collision to an in-flight call rather than removing it, which I reproduced but deliberately did not fix, since it needs a same-server SHA-256 digest collision and closing it properly would mean generation-tagged aliases, which is beyond this PR. |
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 51bfb0cae0
ℹ️ 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".
|
@codex review |
|
Codex Review: Didn't find any major issues. Another round soon, please! 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". |
The exporter reads the raw tool name out of provenance, but nothing asserted it: dropping that argument left every formatter and export test green while the exported label regressed to the alias.
51bfb0c to
428c8e4
Compare
|
@codex review |
|
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". |
|
Correction to my previous comment, and a force-push: That comment said
The assertion now checks the rendered output, which is how every other test in that file works, and additionally asserts the alias never leaks into the export. Folded into the commit that introduced it rather than added as a separate fix. Verified: the whole No production code changed between I also ran the branch merged with current main through a staging CI run to check for drift, since main has moved several times today. The merge is clean and no new upstream commit touches |
Lyxot
left a comment
There was a problem hiding this comment.
Approving on the state at 428c8e4.
The problem is real: on main a composed MCP name failing ^[a-zA-Z0-9_-]{1,64}$ is dropped with only a log line while Settings keeps counting the tool, which silently loses every dotted name and every name past 41 characters. Aliasing them and resolving back to the raw name at dispatch, approval and display is the right shape, and I traced every consumer of an mcp__ name on both the backend and the frontend without finding one that was missed.
What I checked rather than assumed:
The change cannot disturb a tool that already worked. The separator fold is the identity on the whole character set that could ship before, verified exhaustively per character and across 200k generated names, and for a name with no alias entry the raw-name lookup returns exactly what the old split returned. So classification and dispatch are unchanged for every tool that shipped on main, and the new behaviour is reachable only by names that previously did not exist at all.
End to end, a server advertising get_weather, catalog.get-catalog-entity, a 49-character tool and delete.catalog-entity now ships all four within the 64-character limit, dispatches each to its own raw name, shows the real name on the card, prompts on the destructive one and stays silent on the reads, with get_weather keeping byte-identical naming.
Merges cleanly with current main, and no commit landed today touches tools.py, tool_loop_controller.py, studio_tool_loop.py or the frontend chat utils.
Two things a maintainer should weigh rather than take from me:
Upstream CI has not completed on this head; the Backend CI run has been queued with no job started for some time. My evidence is a staging run of the same tree in a fork, where Frontend build + bundle sanity passes, plus local runs: 2809 backend tests, the full npm run typecheck across both projects, and 7719 of 7720 frontend tests. The single frontend failure is every locale keeps the shortcut in the threshold description, which reproduces on latest main alone with nothing from this branch present, so it is a main regression rather than a cost of this PR.
The in-flight alias redirect discussed above is genuine and deliberately left open. If a catalog refresh advertises a tool whose literal name equals another tool's sanitized stem plus the first 8 hex of its SHA-256, a call already in flight resolves to the new tool. Closing it needs generation-scoped resolution, which is a larger mechanism than a same-server digest collision warrants, and the alternative behaviour is the bug fixed in 8341b0b.
Disclosure: I wrote four of the commits here, so treat this as one signal on a change I am partly the author of, not an independent review of the whole.
…ai#11051) * Studio: alias MCP tool names that are not valid function names instead of dropping them * Studio: keep MCP tool aliases resolvable after the tool cache is evicted * Studio: drop a stale MCP alias when its name ships directly * fix(studio): classify MCP tool names by term, whatever separates them The approval classifiers find a verb by its term boundaries, and those patterns treat only `_` and `-` as separators, because until now a name could not reach them containing anything else. Aliasing changed that: the raw name a tool is dispatched under is what gets classified, and MCP allows a dot in it. So a tool named `get_file.delete` classified as ordinary work while `get_file_delete` prompted, and `read_file.secret` disclosed credentials without asking. In auto mode both ran with no approval prompt. These are exactly the names that used to be dropped and now ship, so the gap arrived with them. Fold every separator to `_` where the raw name enters each classifier, rather than teaching a dozen patterns about dots. A verb behind a `.`, a `/` or a space is now its own term, and camelCase keeps its existing split. This also stops a spurious prompt: `catalog.get-catalog-entity` used to fail closed as high risk because the dot hid its `get` from the known-verb check. * fix(studio): name the real MCP tool in alias diagnostics Two places still showed an alias where the tool's own name belongs. `execute_tool` reported a missing server as `MCP server for tool 'catalog_get-catalog-entity_b9d734f2' not found`, because it resolved the raw name only after that check. Resolve first, so the error names the tool the user knows. A tool whose alias slot was already taken by another tool's real name was logged as a duplicate, which it is not, and the log is the only evidence that a tool went missing. Give it its own message and leave the duplicate warning to actual duplicates. * refactor(studio): derive the MCP alias name budget from the name limit The stem an alias keeps was truncated at `55 - len(prefix)`, where 55 was the 64-character `function.name` limit with the alias suffix already subtracted by hand. Name both, so the arithmetic says what it is and the two move together. A prefix longer than the budget now yields an empty stem instead of a negative slice that would silently truncate from the wrong end. Also document why an aliased tool repeats its raw name in its description, and why valid names claim their spelling before any alias is minted. * test(studio): cover the raw MCP name reaching the markdown export The exporter reads the raw tool name out of provenance, but nothing asserted it: dropping that argument left every formatter and export test green while the exported label regressed to the alias. --------- Co-authored-by: Daniel Han <[email protected]> Co-authored-by: Lyxot <[email protected]>
MCP tools with a dot in the name (like Backstage's catalog.get-catalog-entity) or a name longer than 41 characters never reached the model. Settings still said "Connected (6 tools)", but the model said the tool did not exist or picked a similar one. The MCP spec allows these names, but OpenAI style tool names do not.
Instead of skipping them, Studio now gives these tools a short valid name and maps it back to the real tool when it is called. Approval checks use the real tool name. The tool card, the approval prompt and the chat after a page reload all show the real tool name. Tools with normal names are unchanged.
With an MCP server that has dotted and long tool names, the model on main could not use them. With this change it calls catalog.get-catalog-entity and the 42 character tool and gets their results, the approval prompt and tool card show their real names before and after reloading the page, and get_weather still works and looks the same. Updated the tests that expected the old behavior and added new ones.