fix(mcp): stop the default timeout silently shortening a wait pause - #2587
Open
Avinash Gola (avinashgola) wants to merge 1 commit into
Open
Avinash Gola (avinashgola) wants to merge 1 commit into
Avinash Gola (avinashgola) wants to merge 1 commit into
Conversation
`wait` with `for="time"` capped the requested pause at `timeout`, which defaults
to 2000ms — the same value as the default pause. So the cap only ever bit when
the caller explicitly asked for something longer, and it bit silently:
wait { page, for: "time", value: 10000 } -> "waited 2000ms"
Nothing in the tool description mentions the cap; it documents
`for="time" (default) pauses value ms (default 2000)`. The result even reports
`matched: true`, so an agent has no signal that its pause was cut to a fifth of
what it asked for. 10s is well inside the tool's own 30s ceiling — only the
*default* of an unrelated argument blocked it.
The requested pause now governs. A caller-supplied `timeout` still caps it,
since that is their own explicit ceiling, and `MAX_WAIT_TIMEOUT_MS` remains the
hard limit either way. Nothing changes when no pause or no timeout is given.
The contract case is already named "wait: for=time elapses at least the
requested duration" but only exercised 800ms, under the default; it now also
covers a 3s pause, which is the case that was broken.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Contributor
|
PR author is not in the allowed authors list. |
This branch has not been deployed
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.
The bug
waitwithfor="time"capped the requested pause attimeout:DEFAULT_WAIT_TIMEOUT_MSandDEFAULT_PAUSE_MSare both2_000. So the cap never bites on a default call — it only bites when the caller explicitly asks for something longer, which is exactly when they meant it. And it bites silently:A fifth of the requested pause, reported as a success. Nothing in the description mentions the cap — it says
for="time" (default) pauses value ms (default 2000). 10s is well inside the tool's own 30sMAX_WAIT_TIMEOUT_MS; only the default of an unrelated argument blocked it.The existing contract case is already named "wait: for=time elapses at least the requested duration" but only exercised
value: 800, under the default — so the invariant it names was never actually tested at a value that could break it.The fix
The requested pause governs. A caller-supplied
timeoutstill caps it, because that is their own explicit ceiling, andMAX_WAIT_TIMEOUT_MSstays the hard limit either way.value: 10000value: 10000, timeout: 5000value: 800, timeout: 5000value: 120000The
timeoutdoc comment now says what it actually does, rather than leaving the interaction undocumented.for="text"andfor="selector"are untouched —timeoutis their deadline and always was.Tests
wait_for_time_honours_a_pause_longer_than_the_default_timeoutdrives the tool throughexecute_toolunder#[tokio::test(start_paused = true)], so it asserts real handler behaviour and still runs instantly. On the old logic:Plus table-driven unit coverage of
pause_duration_msfor every row above, and the contract case extended to a 3s pause — the case that was broken.Not run: the gated
BROWSEROS_BINARYcontract suite — no local BrowserOS build — so the extended contract case is unverified against a real browser. The Rust-side behaviour it mirrors is covered by the tests above.🤖 Generated with Claude Code