context_server: Reset MCP request idle timer on inbound activity#57360
Open
beardfaceguy wants to merge 1 commit into
Open
context_server: Reset MCP request idle timer on inbound activity#57360beardfaceguy wants to merge 1 commit into
beardfaceguy wants to merge 1 commit into
Conversation
The per-request timeout in `Client::request_with` was a fixed `executor.timer(timeout)` armed at request time, with no way for the server to signal "still alive, just busy." Long-running MCP tool calls (`cargo test`, large refactors, codebase reviews — anything that runs beyond `context_server_timeout`) get cancelled at the boundary even when the server is actively working and emitting `notifications/progress`. Track the timestamp of the most recent inbound JSON-RPC frame on the shared `Client` and consult it inside the request loop. Any frame the server sends — response, request, OR notification — bumps the timestamp. The request future computes a per-iteration deadline of `last_activity + timeout` and re-arms the timer; when activity arrives during a sleep, the next iteration extends the deadline. A genuinely silent server still bails after `timeout` of true silence, so the protective behavior is unchanged for misbehaving servers. Uses `BackgroundExecutor::now()` so the timer participates correctly in GPUI test executor's fake clock. Tests: request_times_out_when_server_is_silent progress_notifications_keep_request_alive_past_timeout request_times_out_after_progress_stops Co-authored-by: Cursor <cursoragent@cursor.com>
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.
Closes #56774.
Summary
notifications/progress).last_inbound_activity + timeout).Changes
Test plan
cargo test -p context_server request_times_out_when_server_is_silent -- --nocapturecargo test -p context_server progress_notifications_keep_request_alive_past_timeout -- --nocapturecargo test -p context_server request_times_out_after_progress_stops -- --nocaptureRelease Notes: