fix(mcp): drain elicitation_rx concurrently in run_inline_tool_loop#2548
Merged
fix(mcp): drain elicitation_rx concurrently in run_inline_tool_loop#2548
Conversation
…2542) Phase 3 fix for elicitation deadlock. run_inline_tool_loop called execute_tool_call_erased sequentially without draining elicitation_rx, causing deadlock when an MCP tool sent an elicitation event and blocked waiting for a response. - Change run_inline_tool_loop to &mut self - Wrap each execute_tool_call_erased call in tokio::select! that concurrently drains elicitation_rx and calls handle_elicitation_event - Change handle_elicitation_event to pub(super) for cross-module access - Add regression test with blocking executor that simulates the real MCP deadlock scenario; test times out in 5s if deadlock recurs
d805e32 to
1908fc2
Compare
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.
Summary
run_inline_tool_loop(phase 3 of feat(mcp): elicitation during tool execution — phase 2 #2522)run_inline_tool_loopnow takes&mut selfand wraps eachexecute_tool_call_erasedintokio::select!that concurrently drainselicitation_rxhandle_elicitation_eventvisibility changed topub(super)for cross-module access frommod.rsRoot cause
run_inline_tool_loopcalledexecute_tool_call_erasedsequentially with no concurrent drain ofelicitation_rx. When an MCP tool sent an elicitation event and blocked waiting for a response,execute_tool_call_erasedalso blocked waiting for the tool — classic deadlock.Test plan
cargo +nightly fmt --checkpassescargo clippy --workspace -- -D warningspassescargo nextest run --workspace --lib --bins— 7055/7055 passedelicitation_event_during_tool_execution_is_handledwith a blocking executor that simulates the real MCP scenario; times out in 5s if deadlock recursinline_tool_loop_testsupdated (6 call sites:let agent→let mut agent)Closes #2542