Repository navigation
fix(mcp): answer every request with an id while a tool call runs - #18979
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check [DESIGN-REVIEWED] 57514d2 Description read[DESCRIPTION-READ] c6df574864730bcc830742e8f972a2f3e8ba6c808cd4189545825d4227880429 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing to check. What this change shipsInventory (3 items) — 3 justifiedIntent: stop a new chat's first turn from waiting about 30 s when the shared
[FIRST-PRINCIPLES-REVIEWED] 57514d2 Description read[DESCRIPTION-READ] 35604c6f746691de8a093dd6e390990651dad1d4f79b7d70bfc62a4904f7a168 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
311954d to
7b88ef1
Compare
The busy stdio loop dropped any request other than ping, tools/list and tools/call. A client's version probe (server/discover) then went unanswered and the client waited out its own timeout before reconnecting. Route such requests through the idle dispatcher, which answers an unknown method with -32601 at once.
7b88ef1 to
57514d2
Compare
|
Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE The PR stops the pooled |
Problem / Motivation
Goal: A new chat's first turn is no longer about 30 s late when the shared
kirocrew-corebackend happens to be running another session's tool call.The pooled
kirocrew-corebackend runs one tool call at a time. While a call runs, its stdio loop answers only cancel,ping,tools/listandtools/call; every other request with an id gets no answer, ever. An MCP client can open a connection with a version probe such asserver/discover. A probe that lands while the backend is busy is dropped, so the client waits out its own timeout (about 30 s observed) before it falls back and reconnects. The same probe on an idle backend gets-32601 Unknown methodin milliseconds.Why it matters
Every dashboard session on a host with the MCP gateway's stub sharing on uses the same backend, so any session's in-flight call can push another session's first prompt back by 30 s. Measured on one host: first turns that hit this had a 38.9 s median before the prompt was sent, against 15.6 s without it.
Not a goal
What changed (motivation → approach → change)
Symptom: first turn ~30 s late. Cause: the busy branch drops unknown requests that the idle branch answers with
-32601. Change: the busy branch now sends any other request with an id through the idle dispatcher, so it gets the answer it would get idle. Notifications without an id are still dropped.server/discover(or any unknown method) while a call runs-32601at once-32601at onceFiles:
src/kiro_crew/mcp_shared.py(busy branch),test/test_mcp_shared.py.Complementary to #18841: that PR parks
wait,ask_question,spawn_runandspawn_sub_agentsoff the worker, which removes the most common busy window. Its busy branch keeps the same drop, so any other call on the worker (and the first step of a parked call) still swallows the probe. The two touch the same few lines; whichever lands second needs a small rebase.Backwards compatibility
Compatible: requests that were answered before get the same answers; requests that got silence now get the idle path's answer.
Removes nothing: the change only adds answers to requests that were dropped.
Tests
test/test_mcp_shared.py::TestStdioLoopBusyQueue::test_unknown_method_gets_method_not_found_while_busy(server/discover,resources/list): a busy worker plus that request gets-32601while the slow call is still running.pytest test/test_mcp_shared.py test/test_mcp_shared_cancelled_bound.py214 passed. With the old busy branch restored, both new cases fail. black, flake8, isort clean on the two files.Manual verification
N/A — unit coverage drives the real stdio loop with a blocked tool; no live gateway was restarted.
Related Issues
Closes #18978
Pattern harvest
Rule candidate: review-prompt
Pattern: a busy loop that serves a subset of methods drops the rest instead of answering them the way its idle path does.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license.