Repository navigation
fix(sandbox): keep Qwen Code discovery from starting Playwright MCP - #4140
Merged
Merged
Conversation
Qwen Code 0.23.3 asks every MCP server for prompts/list and resources/list at the start of every turn, whatever the server advertised. The lazy Playwright MCP launcher from #4117 had no answer for them, so the discovery itself started mcp-server-playwright on every Qwen turn. The launcher now answers prompts/list, resources/list and resources/templates/list with the server's own -32601 Method not found while the recorded capabilities lack prompts or resources, and leaves them to the server when it advertises them. Also from the #4117 review: - the started server's protocol version is compared with the version the client was told, not the one it asked for; - PLAYWRIGHT_MCP_* settings in the environment start the server at once; - the manifest records the server file it was recorded from, and a server the session put ahead of it on PATH starts at once; - the container check sends Qwen Code's discovery and covers every argument set. Refs #4117
The lazy launcher replays the client's initialize to the server it starts on a turn's first tool call and waited for the answer without a bound, so a server whose start hangs stalled that tool call for as long as the client waits. After two minutes, the same bound the image build gives the server, the launcher now logs it, kills the server and exits with it, and the client sees the server gone. Refs #4117
Contributor
Author
|
Independent review of PR #4140 at
Runtime (mine)
Source, checked against the pinned bundles by one read-only reviewer (@playwright/mcp 0.0.41, Qwen Code 0.23.3, OpenClaw)
LOW (test gaps; the code is correct today)
INFO
Whole-PR CI at the exact head
Merge: squash with |
tale-code-bot
added a commit
that referenced
this pull request
Oct 29, 2026
The #4140 review noted that nobody had traced what Codex sends at the start of a turn. Traced from source at rust-v0.160.0, the image's pin, whose MCP client is rmcp 3.2.0, it sends: 1. initialize for 2025-06-18, with experimental and elicitation capabilities; 2. notifications/initialized; 3. one tools/list whose params carry only _meta.progressToken. Nothing else is sent before a tool call. The launcher answers all three without the server. The new test holds that, and it fails on a launcher that reads any tools/list params as a page request. Refs #4160
3 of 5 tasks
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
The #4140 review found three start-time paths of the launcher that no test held. Each new test fails on its broken variant and passes on the launcher as it is: - A server that answers the replayed start outlives the deadline. With deadline.cancel() removed, it is SIGKILLed at the deadline and the launcher exits 137 mid-turn. - A notification sent before the server starts reaches it after the replayed start. The test fails when the launcher stops holding the notification or stops replaying it. - A request sent while the server starts reaches it after the request that started it. The test fails when lines after the start are dropped, or when the launcher answers a ping itself instead of the server. The stand-in's STAND_IN_HANG becomes STAND_IN_INIT_DELAY (seconds), so the hang and the slow start share one knob. The one-second-deadline loader is shared by both deadline tests. Refs #4160
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
The #4140 review noted that configured_in_env matches any PLAYWRIGHT_MCP_ name, the Dockerfile's own build ARG PLAYWRIGHT_MCP_VERSION included. That is the intended trade, now stated where the match is made. A name the server ignores costs only the lazy start. A list of the names this server reads would miss one a later server adds, and answer from a stale manifest. Refs #4160
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
The image's container check compared the launcher's tool list and its prompt and resource list answers with the real server's, for every argument set. It never compared the initialize answer, as the #4140 review noted. It now compares that answer too, so a recorded start that drifts from the server it names fails the check with LAZY_INITIALIZE_DIFFERS. Refs #4160
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
The #4140 review noted that nobody had traced what Codex sends at the start of a turn. Traced from source at rust-v0.160.0, the image's pin, whose MCP client is rmcp 3.2.0, it sends: 1. initialize for 2025-06-18, with experimental and elicitation capabilities; 2. notifications/initialized; 3. one tools/list whose params carry only _meta.progressToken. Nothing else is sent before a tool call. The launcher answers all three without the server. The new test holds that, and it fails on a launcher that reads any tools/list params as a page request. Refs #4160
tale-review-bot
pushed a commit
that referenced
this pull request
Oct 30, 2026
The independent review of #4140 left the Playwright MCP launcher with start-time paths that no test held, unit tests that inherited the runner's launcher settings, and four open notes. - New tests hold that a server answering the replayed start outlives the start deadline, that a notification sent before the start reaches the server after it, and that a request sent while the server starts reaches it after the one that started it. Each fails on its broken variant: deadline.cancel() removed, the hold or its replay removed, lines after the start dropped, or a ping answered by the launcher. - The tests strip PLAYWRIGHT_MCP_*, TALE_PLAYWRIGHT_MCP_* and PLAYWRIGHT_BROWSERS_PATH from the environment they inherit. Exported in a developer's shell, one of them failed up to 8 of the 45 tests. - A started server that refuses the replayed initialize is now logged as refusing it, instead of as speaking "None". The turn still goes on, because the client was already told that the start succeeded. - The image check now also compares the lazy initialize answer with the real server's (LAZY_INITIALIZE_DIFFERS). - configured_in_env keeps matching every PLAYWRIGHT_MCP_ name, and its docstring now says why. - Codex 0.160.0's start, traced from its source, is answered without the server, and a test holds it. The start is an initialize for 2025-06-18, notifications/initialized, and one tools/list carrying _meta.progressToken. Closes #4160 Task: TALE-68
yannickmonney
pushed a commit
that referenced
this pull request
Oct 30, 2026
The independent review of #4140 left the Playwright MCP launcher with start-time paths that no test held, unit tests that inherited the runner's launcher settings, and four open notes. - New tests hold that a server answering the replayed start outlives the start deadline, that a notification sent before the start reaches the server after it, and that a request sent while the server starts reaches it after the one that started it. Each fails on its broken variant: deadline.cancel() removed, the hold or its replay removed, lines after the start dropped, or a ping answered by the launcher. - The tests strip PLAYWRIGHT_MCP_*, TALE_PLAYWRIGHT_MCP_* and PLAYWRIGHT_BROWSERS_PATH from the environment they inherit. Exported in a developer's shell, one of them failed up to 8 of the 45 tests. - A started server that refuses the replayed initialize is now logged as refusing it, instead of as speaking "None". The turn still goes on, because the client was already told that the start succeeded. - The image check now also compares the lazy initialize answer with the real server's (LAZY_INITIALIZE_DIFFERS). - configured_in_env keeps matching every PLAYWRIGHT_MCP_ name, and its docstring now says why. - Codex 0.160.0's start, traced from its source, is answered without the server, and a test holds it. The start is an initialize for 2025-06-18, notifications/initialized, and one tools/list carrying _meta.progressToken. Closes #4160 Task: TALE-68
tale-code-bot
added a commit
that referenced
this pull request
Oct 30, 2026
The independent review of #4140 left the Playwright MCP launcher with start-time paths that no test held, unit tests that inherited the runner's launcher settings, and four open notes. - New tests hold that a server answering the replayed start outlives the start deadline, that a notification sent before the start reaches the server after it, and that a request sent while the server starts reaches it after the one that started it. Each fails on its broken variant: deadline.cancel() removed, the hold or its replay removed, lines after the start dropped, or a ping answered by the launcher. - The tests strip PLAYWRIGHT_MCP_*, TALE_PLAYWRIGHT_MCP_* and PLAYWRIGHT_BROWSERS_PATH from the environment they inherit. Exported in a developer's shell, one of them failed up to 8 of the 45 tests. - A started server that refuses the replayed initialize is now logged as refusing it, instead of as speaking "None". The turn still goes on, because the client was already told that the start succeeded. - The image check now also compares the lazy initialize answer with the real server's (LAZY_INITIALIZE_DIFFERS). - configured_in_env keeps matching every PLAYWRIGHT_MCP_ name, and its docstring now says why. - Codex 0.160.0's start, traced from its source, is answered without the server, and a test holds it. The start is an initialize for 2025-06-18, notifications/initialized, and one tools/list carrying _meta.progressToken. Closes #4160 Task: TALE-68
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.
Follow-ups from agent #2's post-merge review of #4117 (record 5967420579), all in the lazy Playwright MCP launcher (
services/sandbox-runtime/tale-playwright-mcp).What changed
MEDIUM: Qwen Code turns no longer start the server during discovery.
chunks/chunk-N7VWZDWW.js,discoverAndReturn→listMcpPrompts/listMcpResources) sends rawprompts/listandresources/listwithparams: {}, besidetools/list. It does this whenever the server does not advertise the capability, and it reads code-32601/Method not foundas an empty list.prompts/list,resources/listandresources/templates/listwith{"code":-32601,"message":"Method not found"}while the recordedinitializecapabilities lackprompts(orresources).[email protected],lib/mcpBundleImpl.js,_onrequest).{tools: {}}only (lib/mcp/sdk/server.js).discoverPrompts/discoverResourcescheckgetServerCapabilities()).opencode-linux-x64binary) gates its prompt list ongetServerCapabilities()?.prompts.claude-code-linux-x64binary) uses an SDK whoselistPrompts()/listResources()return an empty list, with nothing sent, when the capability is not advertised.LOW: the version-mismatch log. The started server's protocol version is now compared with the version the client was told (the manifest's answer), not the version it asked for.
2025-11-25, its SDKs'LATEST_PROTOCOL_VERSION, and the pinned server answers2025-06-18.LOW:
PLAYWRIGHT_MCP_*settings. Any non-emptyPLAYWRIGHT_MCP_*variable starts the server at once. The manifest is keyed by the arguments only, butPLAYWRIGHT_MCP_CAPS,PLAYWRIGHT_MCP_CONFIGand the others change the server's tools.LOW: a session-installed
@playwright/mcp.realpathofmcp-server-playwrightasPATHfinds it.PATHfinds another file starts that server at once.PATHis not resolved a second time.LOW: a hung start.
initializewithinSTART_TIMEOUT_S(120 s, the same bound the image build gives the server) is killed.the server did not answer its start within 120 s, ending itand exits with the server (137). The client then sees the server gone instead of a tool call that waits.INFO: the container check covers argument set
[0]only.container-sandbox-runtime-test.tsnow runs for every argument set in/opt/tale/playwright-mcp/args.json:browser_navigatestill runs on set[0].Also:
HTTPS_PROXY/NO_PROXY. Onmainit failed in any runner whose environment carries a proxy, this agent sandbox included.tests/manual/reference/automation.md(the Playwright MCP row, formerly:192), the launcher's docstring,services/sandbox-runtime/README.mdand the Dockerfile comment.Decisions on the remaining INFOs
python3from a session-writablePATH: no change. The launcher runs as the agent's own user, inside the agent's own session. Apython3the session puts first onPATHcan do nothing the session cannot already do. Pinning an absolute interpreter would also tie the script to the base image's layout, while the unit tests run it with the host'spython3.TALE_PLAYWRIGHT_MCP_EAGERis wired nowhere: kept as the documented manual switch (README) for an operator who suspects a manifest. No platform setting sets it, by design.buildMcpServersemits: not changed here.buildMcpServersand the Codex path build the args from the same constants the export lists (PLAYWRIGHT_MCP_ARGS,PLAYWRIGHT_VISION_ARGS).golden-exec.test.tspins every harness's args byte for byte.-cTOML, OpenCode command arrays) out of the golden execs is a follow-up if the reviewer wants it.How I verified it
services/sandbox-runtime/daemon/src/tale-playwright-mcp.test.ts(bun test):main's launcher, the new tests fail: 7 fail / 11 pass.startedline), both version-log cases,PLAYWRIGHT_MCP_CAPS, a session server first onPATH, and the hung start (a 5 s timeout).startedline:initializeasking for2025-11-25,notifications/initialized,prompts/list {},resources/list {},tools/list {},resources/templates/list {}.deadline.start()fails the hung-start test.@playwright/[email protected](Playwright1.56.0-alpha-2025-10-01, browser download skipped).playwright-mcp-args.json.browser_navigateremoved. The script is attached to TALE-501.MCP_LAZY_DISCOVERY_OK 21. For both sets, the server was not running after discovery, and the tool list and the three-32601answers equal the real server's own.main's launcher:LAZY_SERVER_STARTED_EARLY 0. The MEDIUM reproduced against the real server.oxlint --type-awareon the changed.tsfiles: clean.tsc --noEmitfor@tale/sandbox-runtime-daemon: clean.oxfmtran through the pre-commit hook.bun run lint:manual: ok.build.yml, "Validate sandbox runtime behavior").Closes #4126