Repository navigation
perf: send the first prompt without waiting for user MCP servers - #35722
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks. Folding each MCP frame as it arrives, and not holding the prompt when its Notes
[DESIGN-REVIEWED] 32d6306 Description read[DESCRIPTION-READ] 9f491e75911ac1d14b158a14f1f17d084c796821f2245f9486962be4fd31822a 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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Nothing blocks. One out-of-goal mechanism is a note: the extra wording for sessions with more than 256 MCP servers. Notes
What this change shipsInventory (10 items) — 8 justifiedIntent: a person opening a chat gets their first reply without waiting for their own MCP servers, and is never told a server that is only late is missing. FIX plus ADDITION.
[FIRST-PRINCIPLES-REVIEWED] 32d6306 Description read[DESCRIPTION-READ] 72c454eb042b774f2497bf768a2cf6697f047c0992616647b31887de0cf77bfe That sha256 names the PR description this verdict read. 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: |
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: |
259739a to
6a43634
Compare
Sensitive Change ReviewSensitive files changed:
|
buluoray
left a comment
There was a problem hiding this comment.
Request changes on 6a43634. This PR makes a new KAS chat start about 3 to 5 seconds sooner, because the first prompt no longer waits for the user's own MCP servers. The dashboard and channel turns make up for that wait: they tell the model which servers are still starting, and the model can wait for one with mcp_server_wait. The rule that drops the wait keys on the existing "a person is waiting" start priority, though, and some places that claim that priority never get the new [MCP SERVERS] block. The clearest case is the CLI chat. It always starts with that priority, and its context builder never installs the reader the block needs, so the block is always empty there. On KAS, the default engine, kirocrew chat and especially the one-message kirocrew chat -m now send their only prompt without waiting for the user's servers and without telling the model that any are still starting. A request that needs one of those servers then fails with "that tool does not exist", which this PR is meant to prevent. Before this change those starts waited up to 5 seconds for those servers. The fix is to drop the wait only where the turn can carry the block: either install the state reader on the CLI builder, or keep the brief wait for any start whose turn cannot be told (at least the one-message CLI run, which has a single turn). Please add a test for that path. Everything else checked out. The required Kiro Crew servers are still waited for, and a start still fails when one of them fails. Starts that nobody waits on keep their brief wait. The change reaches only harnesses that declare the MCP readiness barrier, so kiro-cli, claude and the other ACP backends behave as before. The new tool reads only the calling session's own report. Decisive lines: src/kiro_crew/acp/mcp_start_wait.py:53, src/kiro_crew/cli_chat.py:386, src/kiro_crew/cli_chat_context.py:170, src/kiro_crew/context_assembly/mcp_servers.py:133
6a43634 to
963821c
Compare
Sensitive change review
|
Code change approver recommendation: A person should decideWhy: the decider thinks the change is probably fine but estimates a 15% chance that this change introduces a defect, above the 12% limit for approving on its own. I recommend approving. Only a start someone is waiting on (FOREGROUND) skips the wait for the user's own MCP servers. Kiro Crew's own servers are still required, and unattended starts (children, cron, hooks) keep the brief wait. turn_is_told decides when the prompt is about to go out: a prompt skips the wait only if it carries the block's random marker, the block names every skipped server still starting (one still_starting check), and the report is not partial. Any other first prompt, and any prompt on a host that never reports, waits up to 5 s as before, without reading the session queue. Both prompt() and command() go through this wait. The reader loop folds a frame only into the report of the session it names. Frames held back during start are folded once, when the session registers. Every MCP turn event comes from a frame, so the shared runtime only republishes on them. mcp_server_wait needs a strict session key and reads the caller's own report through the keepalive route, which already checks the caller. Server names are fenced, checked for injected instructions and scrubbed. mounted_servers has no callers left, the specs were updated in the same change, and CI and all revie An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit |
buluoray
left a comment
There was a problem hiding this comment.
Request changes on 963821c. Thank you for the new push. It fixes the earlier lane findings about the report: a host that never reports its servers no longer has every server read as still starting, and Kiro Crew's own drop records no longer count as the host reporting. The point from our earlier change request is still open, though. The rule that skips the wait for the user's own MCP servers still keys on the "a person is waiting" start priority. The CLI chat always starts with that priority, and its context builder still has no reader for server states, so the new [MCP SERVERS] block is always empty there. On KAS, the default engine, kirocrew chat and the one-message kirocrew chat -m send their first prompt without waiting for the user's servers and without telling the model that any are still starting. A request that needs one of those servers can then fail with "that tool does not exist". Before this change those starts waited up to 5 seconds. Please either install the state reader on the CLI builder, or keep the brief wait for a start whose turn cannot be told, at least the one-message run. Please also add a test for that path; none covers it today. Separately, the GPT 6.1 lane blocks this head with a finding of its own, which is not part of this change request: after a user removes a server that the model was told had failed, the block can tell the model that the removed server is now connected. Please answer that one on the lane's comment. Everything else we checked is unchanged and sound: Kiro Crew's own servers are still waited for, a failed required server still fails the start, starts that nobody waits on keep their wait, and only harnesses with the MCP readiness barrier are affected. Decisive lines: src/kiro_crew/acp/mcp_start_wait.py:53, src/kiro_crew/cli_chat.py:386, src/kiro_crew/cli_chat.py:443, src/kiro_crew/slack/gateway_runtime/service_boot.py:354, src/kiro_crew/context_assembly/mcp_servers.py:133
Withdrawn. The point about the CLI chat's first prompt was wrong: kiro-cli itself sends the first prompt without waiting for the user's MCP servers, so this PR matches the existing behaviour there and is not a regression.
Sensitive change review
|
9ff798f to
a4b4a6c
Compare
Sensitive change review
|
A session's MCP report was filled only while the session started. A server that connected later stayed "no report" for the whole session: status frames read during a turn fed sign-in tracking only, the pre-turn drain dropped them, and between turns nothing read them. The report now follows each server for as long as the runtime reads. A frame that names a session is folded into that session's report once, where it arrives: in the reader loop before routing, and in the copy of the frames staged while the session id was unknown. The start drain, the pre-turn drain and the turn loop fold nothing. The report is opened together with the session's queue, so no frame can precede it. A real mode switch drops what frames reported before the switch was requested, which is what the drain's stale-frame skip did. The report names every state a server can be in (connecting, failed, needs sign-in, disabled, dropped by a registry) and carries them in its payload as `states`, with `states_omitted` counting the servers its lists leave out. A reader is told when the report changed through `set_mcp_report_changed_hook`, so nothing has to poll. The chat sets the hook at turn admission and republishes its copy, so a server that connects between turns reaches the MCP panel. A turn's MCP event on the runtime's report only republishes it: the frame behind the event was folded on arrival, and writing the event again could put an older state over a newer one. For the same reason the readiness barrier no longer writes the servers it saw connect. Closes #35509
A chat's first prompt waited up to five seconds for every MCP server the agent declares, the user's own included, though most first prompts use none of them. Kiro CLI does not wait for them. When a person is waiting on the start, the prompt now waits for Kiro Crew's own servers and, briefly, for the ones Kiro Crew sent on the session (a Connection's bridge, a routed stub), and no longer for the agent's own. A start nobody is waiting on (a sub-agent child, an unattended run, a re-sent server set) waits as before. The rule is stated once, in acp/mcp_start_wait.py. Not waiting is safe only for a turn that is told which servers are still starting, so the start leaves the servers it skipped to the session's first turn. A prompt whose block names each of them that is still unreported goes out at once. Any other first prompt (kirocrew chat, a side question, a one-shot, a command) holds for them as the start did, at most five seconds, reading no frame off the session's queue. The fact is read off the prompt when it is sent, never declared. The block's still-starting row names every server the session's report holds (256), so 100 servers still starting are each told and the prompt goes out. An agent with more of its own than that has the surplus counted, and its first prompt holds. One function answers which servers are still starting (McpSessionReport.still_starting). The block's still-starting row is made by it, and the hold and its decision read it over the servers the start skipped, so a settled server (connected, failed, needs a sign-in, switched off, disabled by the host, dropped by a registry) never holds a prompt, and one still starting is named or the prompt holds. A server that is still connecting is not in the model's tool list, and the host's loader answers a request for its tool as though it did not exist. So the turn now tells the model: a [MCP SERVERS] block on the context rail lists each server the session cannot use by its state, from the session's live report, and says what to do. For one that is still starting the model tells the user in a sentence, calls the new mcp_server_wait tool once, then loads the tool and finishes the task. The wait parks, asks the gateway for the calling session's own report on the existing keepalive route, and returns the moment the server has connected, or says why it will not. The session's report now keeps a server's status by name for up to 256 servers, where it kept 64. With 64 of the user's servers the host lists Kiro Crew's own four after them, so they were never read and the model would have been told on every turn that they were still starting. The session's sign-in tracker reads as far into a snapshot as the report does. A server is called still starting only on a host that has reported something: one that never reports its servers claims nothing. The states are read through not_ready() by the block and the wait tool. payload() does not carry them: nothing reads them off it in this change. A rebuilt context window (a new conversation, a compaction) is told a settled state again. A name no report holds is never called missing. A server named earlier is called connected only when the report holds it as connected, never because it stopped being listed. One bound (256 names) holds every list of server names the not-ready reading joins. "Still starting" is claimed only from what the host itself reported, never from what Kiro Crew recorded. Every list of the report is cut by one helper (mcp_report_bound.keep), which answers what it kept and how many names it left out. A report that left a name out is partial: only a server the host lists as starting is called still starting, no first prompt counts as told, the block says once how many servers are not tracked, and mcp_server_wait answers at once.
a4b4a6c to
32d6306
Compare
Sensitive change review
|
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Review of head 32d6306 found nothing that blocks. The review traced the new arrival fold from the reader loop and both start-path replays. It uses the same positive ownership test as before (the frame's sessionId must match the session). The first-turn hold runs only on harnesses that report MCP readiness. A prompt goes out early only when the block's own mark is in that prompt and every skipped server is named in it. Every unknown or partial case falls back to the old 5 s hold. Mutation runs on 29 touched test files showed that removing the reader-loop fold, the consent fold, any clause of turn_is_told, or the wait deadline each makes a test fail. Well done: every uncertain case falls back to the old behaviour, so the speed-up only happens when the code can prove the prompt is safe to send.
Security: the keepalive route still goes through internal_memory_scope with the claimed session key, reads only that session's own provider, and limits mcp_server to 128 characters. mcp_server_wait uses require_strict_session_key, so a sub-agent cannot read its parent's servers. Its input is checked against a schema, and the names it returns are redacted and JSON-quoted. Server names in the [MCP SERVERS] block are screened for injection, marker-neutralised and fenced with a nonce, and failure reasons are never shown. No auth path, sandbox or secret path changed.
- Optional: the handling for sessions with more than 256 servers (mcp_report_bound.py, the "not tracked" row, mcp_reports_left_out, _UNKNOWN_LEFT_OUT) could shrink to one partial flag on the report. That flag alone fixes the 90 s wait and the false "connecting" claim.
- Optional: add one test in test_mcp_server_wait.py that puts an answered "connecting" between missed requests. Today you can delete the
self.unanswered = 0reset in mcp_wait.py:152 and every test still passes. - Optional: the timing tables come from earlier heads, and the body says the head numbers are still to come. Post the head numbers, or say plainly that the timings were taken before rounds 3 to 7. The macOS data also shows prompt three about 1 s slower at 64 servers.
Problem / Motivation
Goal: A chat's first prompt no longer waits for the user's own MCP servers, and the model and the chat always know which servers are still starting, so a server that is merely late is never reported as missing.
Two things were wrong together.
Fixing 1 alone would make 2 worse, so they ship together: commit 1 makes the report follow its servers, commit 2 removes the wait and tells the model.
Why it matters
Not a goal
stateskeys onpayload()with their reader.[MCP SERVERS]block.What changed (motivation → approach → change)
Commit 1,
fix(acp): keep a session's MCP report current after it starts.AcpRuntime._fold_mcp_frame), so the report moves during and between turns. No drain folds; the fold never raises into the reader.folded_on_arrival: a turn's MCP event only republishes it. A real mode switch forgets earlier reports (forget_reported).not_ready()puts each unusable server in exactly one ofdisabled,registry_dropped,needs_sign_in,failed,connecting. Its readers are the block and the wait tool below;payload()does not carry it.connectingis claimed only once the host itself has reported a server, never from what Kiro Crew records, so a host that reports nothing claims nothing.on_change, set throughLLMProvider.set_mcp_report_changed_hook; the chat sets it at turn admission (src/kiro_crew/dashboard/chat_turn/mcp_session.py) and a re-opened session hands its reader over.Commit 2,
perf(acp): send the first prompt without waiting for user MCP servers.src/kiro_crew/acp/mcp_start_wait.py): Kiro Crew's own servers are required; servers it sent on the session get the brief 5 s; the agent's own get it at a start nobody waits on. A start a person waits on (StartPriority.FOREGROUND) leaves them to the first turn: a prompt whose block names each of them goes out; any other holds the same 5 s (src/kiro_crew/acp/session_handle_mcp.py,src/kiro_crew/acp/session_handle_turn.py).src/kiro_crew/context_assembly/mcp_servers.py, installed insrc/kiro_crew/slack/gateway_runtime/service_boot.py): a[MCP SERVERS]block on the turn's context rail lists each unusable server by state, names fenced and screened, and says what to do: every turn while one is still starting, once per change otherwise. It is context, not the user's words.src/kiro_crew/mcp_tools/control_parts/mcp_wait.py):mcp_server_wait(server)parks, asks the existing keepalive route for the calling session's own report (src/kiro_crew/dashboard/handlers/sessions_parts/live_turn.py), and returns when the server connected, at once for a state waiting cannot change, or after 90 s. A name no report holds is never called missing. No new listener. It is a job tool of every shipped agent (63 tokens); two conductor rows measure 7,653 and 7,808 with it, so their budgets go to 7,700 and 7,850.src/kiro_crew/security_posture.pylists the tool's module beside its sibling tool handlers.src/kiro_crew/context.py), its name on the block list (src/kiro_crew/context_blocks.py); the state reading issrc/kiro_crew/agent_sdk/mcp_problems.py. The tool's schema, registry row, title, module list and job-tool row:src/kiro_crew/validation.py,src/kiro_crew/validation_parts/messaging_session_schemas.py,src/kiro_crew/validation_parts/server_registries.py,src/kiro_crew/data/mcp_tool_titles.json,src/kiro_crew/mcp_core_parts/identity.py,src/kiro_crew/agent_sdk/tool_search.py. Docs:docs/system-specs/modules/learn-cron-dashboard.md,src/kiro_crew/docs/configuration.md,src/kiro_crew/docs/troubleshooting.md. The hook andstart_prioritycrosssrc/kiro_crew/providers/base.pyandsrc/kiro_crew/providers/acp_runtime_start.py.STATUS_CAP), holds every list of server names the reading joins (the status buckets, the wire roster, declared, muted and registry-dropped servers) where each held 64, and the sign-in tracker reads as far. At 64 user servers the host lists Kiro Crew's own four last; unread, they were named as still starting on every turn.unchanged)changed)changed)added)added)unchanged)Legend: added, changed, removed, unchanged.
Backwards compatibility
Compatible:
payload()keeps every key and gains none;mcp_server_waitis a new tool; the keepalive route's reply gainsmcp_server_stateonly when the body namesmcp_server;[MCP SERVERS]is a new context block;create_sessionalready tookstart_priority,load_sessionand_load_session_with_retrygain it with the old behaviour as the default.payload()'sconfigured,ready,failedandawaiting_authlists can now hold up to 256 names where they held 64; the block's still-starting row names up to 256 servers; the sign-in tracker reads 256 entries of a status snapshot where it read 64;roster_nameskeeps its bound of 64 for its other callers, and the sign-in sets are unchanged.Changed on purpose: a person's first prompt can go out before the user's servers have connected, so a first turn that needs one of them now waits inside the turn (the model says so and calls
mcp_server_wait) instead of before it. That is so only for a turn that is told of them: a dashboard chat turn or a channel message. A first turn that is not told (kirocrew chat,kirocrew chat -m, Side Chat, a Bot reply thread, a one-shot) still waits up to 5 s for them; that wait now sits just before the prompt instead of at the end of the start. Every start nobody is waiting on is unchanged.Takes away one public function,
mounted_serversinsrc/kiro_crew/acp/mcp_session_report.py.git grep -n mounted_servers origin/main -- src test docs websitefinds one reader, the session start barrier, which every entry point's session start goes through; it now callsfirst_prompt_brief_wait:Reader: src/kiro_crew/acp/runtime_session_load.py:_wait_managed_mcp -- chat -- test_mcp_start_wait.py::TestTheStart::test_a_person_waiting_still_waits_briefly_for_a_session_sent_server
Reader: src/kiro_crew/acp/runtime_session_load.py:_wait_managed_mcp -- cron -- test_mcp_start_wait.py::TestTheStart::test_a_start_nobody_waits_on_still_waits_for_the_users_servers
Reader: src/kiro_crew/acp/runtime_session_load.py:_wait_managed_mcp -- subagent -- test_mcp_start_wait.py::TestTheStart::test_the_default_is_the_start_nobody_waits_on
Merge order: this PR first, then #35564, which adds
statesandstates_omittedtopayload()together with the display that reads them.Tests
Commit 1 (the live report):
test/test_mcp_report_arrival_fold.py(new, 48). Each unusable server is in exactly one state; a full list of ready servers does not crowd a connecting one out; a state lists at most the cap, and a declared server the wire also names is named once; the payload does not carry the states; the largest set measured (64 user servers and Kiro Crew's own four, listed last) is described whole; every list the reading joins holds as many names, and a declared server the registry dropped is never called connecting; what Kiro Crew records itself (a pruned server, a mount-check finding) does not make a silent host heard, and a turn event from the host does (test/test_kas_governed_mcp_drop.pypins the same for a governed drop); the hook fires on a change and only then, and a hook that raises does not fail the fold; a mode switch drops only what reported before it; names past the cap leave no mark. Through the runtime's real reader loop: a frame is folded with nothing reading the queue, reaches the session it names and no other, and a frame the fold cannot read does not stop the reader.test/test_mcp_session_report_wiring.py(5 new): an event whose frame was folded on arrival still moves the chat's copy once; a queued older event does not overwrite a newer frame; a server that connects between turns reaches the chat through the hook.test/test_kas_mcp_live_reinject.py,test/test_kas_governed_mcp_drop.py,test/test_kas_mcp_sign_in.py,test/test_kas_session_start_queue.py(one or two new cases each): the reader follows a reloaded session; the readiness barrier writes no older success over a newer failure; the runtime's own consent request is in the report; on the stub engine process a server that answers after the start reaches the report with nothing reading the queue.test/test_acp_runtime_drain_init.py: the six cases that pinned "the drain records the report" are removed; the arrival-fold cases cover them.test/test_mcp_session_report.py: the four bucket-cap cases read the new status cap.Commit 2 (no wait, the model line, the wait tool):
test/test_mcp_start_wait.py(new, 67). The rule: a person waiting does not wait for the agent's own servers; a start nobody waits on keeps the brief wait; a required server is never in the brief set; every server of the agent's is either waited for by the start or left to the first turn, at either priority. The start, on a real_wait_managed_mcp: a person's start returns with the user's servers still connecting, still waits for Kiro Crew's own, still waits briefly for a session-sent server and no longer than the cap; the default is the start nobody waits on; a failed required server fails the start either way; a late server is in the report once it connects. The first turn: one that was not told holds until the servers report and no longer than the cap; a prompt that carries the recorded block goes out while they still connect; a block that was built exempts only the prompt that carries it; a block that leaves out a server the start skipped tells no turn, and need not name one that has reported; a server that goes back to connecting after the build holds the prompt; a skipped server the registry dropped or the host disabled is not waited for and need not be named; every state of the vocabulary, skipped or not, gives one answer to the row, the decision and the hold; 65, 100 and 256 own servers are left to the turn whole, and 300 leave 256 by name and 44 counted, which holds the first prompt to the cap whatever it carries; a reading alone tells no turn; only the first turn holds; a cancelled hold holds the next turn; the hold takes nothing off the session's queue (an awaited response, a permission request and the runtime's death notice stay for the turn).test/test_kas_session_start_queue.py(3 new, a real prompt against the stub engine process): an untold first prompt is written only after the servers reported; a told one is written while they still connect; a start nobody waited on holds nothing.test/test_cli_chat_context.py(2 new,kirocrew chatandkirocrew chat -mend to end on a KAS session): neither builds a block, so the report stays untold and the session holds that prompt.test/test_mcp_servers_block.py(new, 51). The text: state before instruction, names in a nonce fence, the wait offered only for a server still starting, a settled row names twelve then counts, the still-starting row names every server the report holds (256; pinned equal to the report's bound) then counts, the block stays under 450, 600 and 1,300 tokens at 64, 100 and 256 servers, a name that reads as an instruction or forges a context marker is left out. When it is sent: every turn while one is starting, once per change for settled states, nothing for a sub-agent child or a minimal-context turn, the record bounded; a rebuilt window is told a settled state again. A server named earlier is called connected once, by name, only when the report holds it as connected; one that was removed, or is absent from a re-opened session, is never called connected. A block that spells out every server its session's start skipped is recorded under its own mark, a new one per build (thirteen are each named and recorded); at 65, 100 and 256 servers still starting a first prompt built by the gateway's builder is told and goes out through the real hold; a start that left more servers than the report tracks is not told; a block that leaves one out or prints it changed (a name screened as an instruction, a name that holds a context marker), a minimal-context turn, a sub-agent child and a builder with no reader record nothing.test/test_mcp_servers_block_readers.py(new, 6, one per reader, on a real turn): the model is told; the dashboard transcript, a Bot's chat, the browser push, stored history, a channel mirror, the crew log and the audit log carry the user's own words only.test/test_mcp_server_wait.py(new, 35). The route answers with the calling session's own server and only when asked. The state: the report's own word for each server; two servers that differ only by case each answer for themselves, and a spelling that could mean both is unknown and names both; with 64 user servers every server answers; the reading names the connected servers beside the unusable ones. The tool: refuses an unidentified caller, returns the moment the server connected, names a server that will not connect as what it is, gives up at 90 s and never waits past it, survives one lost request, ends when the gateway stops answering, reads a server name back scrubbed, and never calls a server no report names missing. Its clock is installed on the tool's own module.start_priority:test/test_acp_bindings.py,test/test_runtime_bindings.py,test/test_kas_mode_binding.py,test/test_validation_parts_facade.py,test/test_context_composition_contract_facade.py,test/test_remote_session_local_only_tools.py,test/test_context_management_doc.py.test/test_job_tools.py: the pipeline and security conductors' budget, 7,600 to 7,700 (measured 7,653); the goal conductor's, ledger conductor's and team lead's, 7,800 to 7,850 (measured 7,808 on a main where that row had grown to 7,745 without this change).Review round 1 (head
259739aa18), each finding and what changed:statesandstates_omittedonpayload()had no reader in this diff. Removed, with the count plumbing behind them and theNOT_READY_STATESconstant, which only a comment read. Checked as a class: every other name this diff adds has a caller or reader in it (the change hook is set by the chat at turn admission,not_ready()is read by the block and the wait tool,STATUS_CAPby the sign-in tracker).mcp_tools/control_parts/mcp_wait.pycalls a redactor and was unclassified. It is listed beside its sibling tool handlers (a tool result's user-visible surface is a registered sink downstream).Review round 2 (head
6a43634e13), each finding and what changed:from_host=Falseand does not set it._reset_stateon a client built without__init__(test_pid_lifecycle_teardown.py,test_acp_usage_cost.py), now read withgetattr; the control facade's manifest, which now names the nine names it forwards fromcontrol_parts/mcp_wait.py(test_facade_mirror_guards.py); two fake handles intest_mcp_gateway_stub_session_token_minting.py, which now have themcp_session_reporta real handle has.Review round 3 (head
963821ca49), each finding and what changed:Human review (changes requested on
6a43634e13): the wait was dropped on the start priority alone, but only some turns carry[MCP SERVERS];kirocrew chatandkirocrew chat -msent their prompt with no wait and no word to the model. The drop now rests on a fact, not on the priority: the start records the servers it skipped, and the first prompt goes out without waiting only when it carries a block that spells out every one of them still unreported (the block hands the session the names it spells out under its own mark; when the prompt is about to go out the session checks that it holds that mark and that the names cover what it still waits on). Any other first prompt holds up to 5 s for them, as the start did before, without taking a frame off the session's queue. No entry declares which kind it is, so a new entry, a minimal-context turn, a command, a prompt built before its session existed, or one sent after a build that was stopped holds. The CLI keeps the wait rather than gaining the block: on KAS it sends the typed text with no built context, and the wait tool asks the gateway for a session the gateway does not hold, so a block there would point the model at a tool that cannot answer.[MCP SERVERS]test_mcp_servers_block_readers.py::test_the_model_is_told,test_kas_session_start_queue.py::...::test_a_turn_that_was_told_is_sent_while_they_still_connecttest_mcp_servers_block.py::TestATurnThatIsTold::test_a_turn_that_carries_the_block_is_recorded_as_told,test_mcp_start_wait.py::TestTheFirstTurn::test_a_prompt_that_carries_the_block_goes_out_while_they_still_connectkirocrew chat, interactivetest_cli_chat_context.py::test_a_cli_turn_is_not_told_of_a_server_still_starting_so_its_prompt_holds[interactive]kirocrew chat -m[one-message]test_kas_session_start_queue.py::...::test_a_turn_that_was_not_told_is_sent_once_the_servers_reporttest_mcp_servers_block.py::TestATurnThatIsTold::test_a_builder_with_no_reader_tells_no_turn,test_mcp_start_wait.py::TestTheFirstTurn::test_a_turn_that_was_not_told_holds_until_they_reportGPT:
declaredkept 64 names beside a separate overflow list, so readers disagreed (65 declared servers that all connected still read as "1 more, not tracked").declareditself now holds 256 and the overflow list is gone.GPT: the block said a server had connected because it stopped being listed, which is also true of a server that was removed. The reader now carries the report's connected names, and a server named earlier is called connected once, by name, only when it is among them. The sentence "not listed here is connected now" is gone.
Local verifier on the first form of this fix: the record was made when the report was read, so a block that screened a starting server's name out, or a build that was stopped, still exempted a prompt; and the hold read the session's queue, where it could drop a command's awaited response or a permission request. The record is now the block's own mark and must be in the prompt, and the hold reads no queue. A second pass found the row cap: a row named twelve servers and counted the rest, and still exempted the prompt. The still-starting row now names up to 64, and the names a block spells out must cover every server the session still waits on. A third pass found that this was checked when the block was built, and a server can go back to connecting before the prompt is sent. The check is now made once, when the prompt goes out.
The two red tests on that head are in files this diff does not touch.
test_cloud_launch_customize.py::TestAmiArchitectureCheck::test_matching_architecture_proceeds_to_deployfailed on the base and is fixed on main by test(cloud): let the AMI check's fake answer a failed launch's stack lookup #35746; this head is rebased past it.test_remove_slot_for_history_key_crew_log.py::TestSessionLedgerOnPermanentDelete::test_a_ledger_the_emitter_itself_opened_is_still_removedfailed on one of the eight Linux shards and on no Windows shard; the file passes locally (32 of 32).Review round 4 (head
68b7979afe), each finding and what changed:monkeypatch. Both now use_floor_monkeypatch.turn_is_toldinsrc/kiro_crew/acp/session_handle_mcp.py), sosrc/kiro_crew/acp/mcp_session_report.pyis 1,586 lines, under the 1,600 at which a file is split.Review round 5 (head
fc01a4588a), the one finding and what changed:McpSessionReport.still_starting, answers "still starting" from the report's one vocabulary; the block's still-starting row is made by it, and the hold and its decision read it over the servers the start skipped (still_waited_for). There is no second list and no second bound.test_mcp_start_wait.py::TestOneAnswerForEveryState): the row, the decision and the hold agree, a settled server never holds the prompt, and one still starting is named or the prompt holds. On a host that has reported nothing the row claims nothing and the prompt holds, as the start did before.agent.tool_searchrow and a troubleshooting section, "A server's tools are not there yet on a chat's first message".Review round 6 (head
3ef637f597), the one finding and what changed:test/test_mcp_servers_block.pycompared two blocks and rested on two random fence nonces differing. Both now take their nonces from a fixed sequence, set at the module's own binding, and the first asserts each block's opener by value. No other line this change adds to a test rests on a random draw.Review round 7 (head
010f4c98de), the one finding and what changed:mcp_server_waitwaited its 90 s for it. It was the fourth finding about this report's bounds, so the class is closed by construction: one helper (mcp_report_bound.keep, in a sibling module) makes every cut of the report and answers what it kept and how many names it left out, recorded on the report; a source test finds any other slice, and a table runs every bounded list under, at and over its bound. The same one bound now also holds the names a start nobody waits on waits for (256, where it read the first 64; still at most 5 s).mcp_server_waitanswers at once, with that reason. A report that became partial stays partial until its session starts again. Nothing changes for a session within the bound (256 servers).src/kiro_crew/acp/mcp_session_report.pyis 1,580 lines.Proof: not provable -- other: the new test files import names the reverted tree lacks, so prove.py's mutated run errors at collection; reverting by hand only the source of the review follow-ups fails the new cases that cover them
Manual verification
An MCP smoke test, run against the build before this change (main
2df02ab46a) and after it (this diff on the same base,b550ab4136). One isolated gateway at a time, driven through the dashboard's HTTP API, each build on its own interpreter; the user's servers are stand-ins whose tools return a code made at the call, so a reply passes only when it carries a code a real call returned. Linux, kiro-cli 3.2.0, engine 3.2.0, modelclaude-fable-5.2, one run per cell.mcp_server_wait)LATE-7391-OK-7BF6." Tool calls in order:mcp_server_wait, the loader,late_lookup.cron_add, which is not.fb4f71190d: the pushed head's two commits on an earlier main (the lines this diff adds and removes are the same but one test value, which a rebase recomputed, and one line of the troubleshooting page)963821ca49(round 2), main5f48319before3ef637f597(round 5), main5f48319before; cases 2 and 11 again on010f4c98de(same source)32d630670e: the 49 test files this diff touches or pins (the doc path tests main gained among them), 2,898 passed; mypy, flake8, isort, black, the line cap, docs lint, the subprocess-encoding, comment-history, brand and harness-parity checks returned 0, and the flake-pattern ratchet passed. The static test-determinism scan reported no line this diff adds, on that head too. A wider run of 162 test files, on this diff before review rounds 6 and 7, gave 8,525 passed, 1 failed (test_harness_parity.py::test_is_kiro_cli_is_positive, which fails on main on that host).mcp_server_waitfirst; the case passes (19 to 26 s).Time to the first text of a reply, Linux, n = 3 where three values are shown, before = main
2df02ab46a, after = this diff on the same base (b550ab4136, before review rounds 2 and 3), kiro-cli 3.2.0 with the v3 engine, seconds:session/newtook 7.58, 7.94, 8.89 before and 2.55, 3.46 after.The same on macOS (Mac mini M2), where 64 servers can be run: main
5f48319against963821ca49, default backend, kiro-cli 3.2.1 with the v3 engine on both, median of 5 new chats, first prompt sent at once, seconds:Related Issues
Closes #35509
Closes #35678
Sibling sweep
Swept:
git grep -nE "record_frame\(|record_event\(" -- src/Sibling: src/kiro_crew/acp/session_handle_mcp.py -- changed here
Sibling: src/kiro_crew/dashboard/chat_turn/mcp_session.py -- changed here
Sibling: src/kiro_crew/acp/runtime_host_requests.py -- changed here
Sibling: src/kiro_crew/acp/client_transport.py -- not affected -- the dedicated client folds in its drain, where its buffer index says which session attempt a frame belongs to
Sibling: src/kiro_crew/subagent_manager/run_start.py -- not affected -- a child passes no start priority, so it waits as before
Pattern harvest
Not generalizable: the freeze came from one design choice (a report written by the readers of a queue instead of at the queue's one entry), and the wait from one rule that did not ask who was waiting; neither is a code shape a lint could match.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.