Skip to content

perf: send the first prompt without waiting for user MCP servers - #35722

Merged
bolichen97 merged 2 commits into
mainfrom
fix/live-mcp-session-report
Nov 12, 2026
Merged

bolichen97 merged 2 commits into
mainfrom
fix/live-mcp-session-report

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

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.

  1. The first prompt waited for servers it mostly does not use. A session start held the first prompt up to five seconds for every MCP server the agent declares, the user's own included. Kiro CLI does not wait for them.
  2. Nothing knew a server was still starting. A session's MCP report was filled only while the session started, so a server that connected later stayed "no report" for the whole session. And a server that is still connecting is not in the model's tool list: the host's loader answers a request for its tool as though it did not exist, so the model told the user the server was missing.

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

  • Time. Measured on the Linux test host before this change (kiro-cli 3.2.0, engine version not recorded for these rows): a new chat was ready 2.1 s after it was opened with no user servers, and 5.5, 7.7 and 6.9 s with 10, 30 and 64 of them. Without the wait for the user's servers it is ready in about 2.1 s at every count.
  • Truth. With a server that answers 25 s after it starts, asked for on the first prompt, the build before this change gives the model no word that the server is starting. In the Linux run it went looking through config files, slept in a shell and then found the tool (7 tool calls); the reply never said the server was loading. On Windows the same case fails on main on both backends. After this change the reply says the server is still starting, waits for it with one call, calls its tool and returns the result in the same turn.
  • With 30 or 64 servers most of them connect after the session has started, so without a live report every one of them reads as "no report" in the chat's MCP panel for the whole session.
  • What it moves, not removes. A request whose tool list changed since the one before waits longer at the provider. Measured on macOS at 64 servers, on the build that already released the prompt earlier (kiro-cli 3.2.0 and 3.2.1, v3 engine): 0.5 to 0.9 s more after the request is sent, and about 0.3 s more before it while the machine is still starting servers. It is paid once per changed tool list, in the first minute of a chat, and Kiro CLI pays the same at the same delays. Seconds saved against tenths lost. The first, second and third prompt at 10, 30 and 64 servers, before and after, with the model wait split out and Kiro CLI beside it, are being measured on this head and are added here.

Not a goal

  • Any new dashboard display. The chat's existing MCP panel is kept current. Drawing a loading state is a separate change (feat(dashboard): show a session's MCP servers still connecting #35564), which merges after this one and brings the states keys on payload() with their reader.
  • A re-opened chat. It still waits for Kiro Crew's own servers behind the user's; that is a separate change on top of this one, which reuses the rule, the block and the tool added here.
  • Sub-agent children, unattended runs and a re-sent server set: each waits exactly as before, and a child gets no [MCP SERVERS] block.
  • The engine: how long it gives a server, its second process per server for protocol negotiation, and the order of its tool catalogue. That catalogue is one tool's description with the tool ids sorted by name, so a server that connects between two turns changes it in the middle. Kiro Crew does not build that text. This PR adds only to the end of a request (the new user turn). The first request now carries Kiro Crew's own four servers and whichever of the user's connected in the first second or two, so its catalogue is not the same from chat to chat (in the smoke runs a server that answers in 0.3 s was in it in some chats and not in others). Declaring the user's servers to the engine only after the first request would make it the same in every chat, and would start every one of them that much later; that is not done here, and the prompt is not held for it.
  • The dedicated client (harnesses that do not run on the shared runtime): its report moves at its drains and turn events, as today.

What changed (motivation → approach → change)

Commit 1, fix(acp): keep a session's MCP report current after it starts.

  • One fold, at arrival. The runtime's reader loop folds each frame that names a registered session into that session's report before routing it (AcpRuntime._fold_mcp_frame), so the report moves during and between turns. No drain folds; the fold never raises into the reader.
  • One writer. The runtime's report is marked folded_on_arrival: a turn's MCP event only republishes it. A real mode switch forgets earlier reports (forget_reported).
  • One vocabulary. not_ready() puts each unusable server in exactly one of disabled, registry_dropped, needs_sign_in, failed, connecting. Its readers are the block and the wait tool below; payload() does not carry it. connecting is claimed only once the host itself has reported a server, never from what Kiro Crew records, so a host that reports nothing claims nothing.
  • Announced. on_change, set through LLMProvider.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.

  • The rule, once (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).
  • The model is told (src/kiro_crew/context_assembly/mcp_servers.py, installed in src/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.
  • The model can wait (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.py lists the tool's module beside its sibling tool handlers.
  • Wiring. The block's reader and told-record sit on the builder (src/kiro_crew/context.py), its name on the block list (src/kiro_crew/context_blocks.py); the state reading is src/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 and start_priority cross src/kiro_crew/providers/base.py and src/kiro_crew/providers/acp_runtime_start.py.
  • A large set is described whole. One bound, 256 names (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.
A person's first prompt, user servers still connecting Before After
Waits for Kiro Crew's own servers yes yes (unchanged)
Waits for the user's own servers up to 5 s no when the turn is told of them; up to 5 s when it is not (changed)
The session's report after start frozen follows each server (changed)
What the model knows of a late server nothing its state, each turn it matters (added)
A request for a late server's tool "that tool does not exist" waits for it once, then uses it (added)
A child, cron, hook, re-sent server set brief wait brief wait (unchanged)

Legend: added, changed, removed, unchanged.

Backwards compatibility

Compatible: payload() keeps every key and gains none; mcp_server_wait is a new tool; the keepalive route's reply gains mcp_server_state only when the body names mcp_server; [MCP SERVERS] is a new context block; create_session already took start_priority, load_session and _load_session_with_retry gain it with the old behaviour as the default. payload()'s configured, ready, failed and awaiting_auth lists 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_names keeps 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_servers in src/kiro_crew/acp/mcp_session_report.py. git grep -n mounted_servers origin/main -- src test docs website finds one reader, the session start barrier, which every entry point's session start goes through; it now calls first_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 states and states_omitted to payload() 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.py pins 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 chat and kirocrew chat -m end 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.
  • Hash and facade pins updated for the new tool and the threaded 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).
  • Determinism: every wait is on a frame, an event or an installed clock; none sleeps.

Review round 1 (head 259739aa18), each finding and what changed:

  • First principles: states and states_omitted on payload() had no reader in this diff. Removed, with the count plumbing behind them and the NOT_READY_STATES constant, 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_CAP by the sign-in tracker).
  • Opus: the block's "already told" record survived a new conversation and a compaction. It is dropped on a rebuilt window.
  • GPT: the wait tool said "this session has no MCP server named X" when no report named it. It now says it has no report of it and sends the model to its tool list.
  • Static ratchet: mcp_tools/control_parts/mcp_wait.py calls 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).
  • PR hygiene: the reader list above.

Review round 2 (head 6a43634e13), each finding and what changed:

  • Opus: "heard" read buckets Kiro Crew fills itself, so on a harness with no status frames one pruned server made every other server read as still starting. It is now a flag set only by a host frame or a turn event made from one; a governed drop, which is Kiro Crew's own finding, is recorded with from_host=False and does not set it.
  • Opus and GPT: muted, registry-dropped, declared and wire-roster names were kept to 64 while the status buckets kept 256, so a declared server past the 64th registry-dropped one read as connecting. One bound holds them all.
  • Three test classes my local runs had not selected, all red on the first two heads: _reset_state on a client built without __init__ (test_pid_lifecycle_teardown.py, test_acp_usage_cost.py), now read with getattr; the control facade's manifest, which now names the nine names it forwards from control_parts/mcp_wait.py (test_facade_mirror_guards.py); two fake handles in test_mcp_gateway_stub_session_token_minting.py, which now have the mcp_session_report a 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 chat and kirocrew chat -m sent 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.

    Entry that claims a person is waiting First turn carries [MCP SERVERS] First prompt holds for the user's servers Test
    Dashboard chat turn (typed, Resume or Continue, a requeued turn), also the first after an eager spawn yes no 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_connect
    A message a person sent on a messaging channel (same builder and reader) yes no test_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_connect
    kirocrew chat, interactive no yes, up to 5 s test_cli_chat_context.py::test_a_cli_turn_is_not_told_of_a_server_still_starting_so_its_prompt_holds[interactive]
    kirocrew chat -m no yes, up to 5 s the same test, [one-message]
    Side Chat, Bot reply threads (their own prompt builders) no yes, up to 5 s test_kas_session_start_queue.py::...::test_a_turn_that_was_not_told_is_sent_once_the_servers_report
    Task Runner Refine and Plan, workflow authoring only when the build reads the report of the session the step runs on yes, unless it did the two session tests above, either way
    One-shots (composer optimizer, Issue Radar's AI routes, member export, STT endpointing, the canary, a Connection's mint) no yes, up to 5 s, when the agent they run declares servers of its own test_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_report
  • GPT: declared kept 64 names beside a separate overflow list, so readers disagreed (65 declared servers that all connected still read as "1 more, not tracked"). declared itself 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_deploy failed 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_removed failed 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:

  • Every review lane passed on that head. The one red check was the static scan: two autouse fixtures this diff added patched through the shared monkeypatch. Both now use _floor_monkeypatch.
  • Found by reading the head: the still-starting row named at most 64 servers, and the start left at most 64 to the first turn. With 100 of the user's servers still starting, the first prompt was not told and held up to 5 s, which is this change's goal failing at 100. One bound now holds here as everywhere else: the row spells out every name the session's report holds (256) and the start leaves as many to the turn, so at 65, 100 and 256 servers the first prompt is told and goes out. An agent with more servers of its own than that has the surplus counted; nothing can say those are named or have reported, so its first prompt holds to the 5 s cap, as its start did before. The block costs a turn 413 tokens at 64 servers still starting, 548 at 100 and 1,133 at 256 (four characters a token, 13-character names), and only while they are starting.
  • Local review of this round: the test for an agent past the bound could pass without the clause it was written for; it now settles every tracked server first, and fails when the clause is removed.
  • The decision "is this prompt told" moved from the report's module to the hold's (turn_is_told in src/kiro_crew/acp/session_handle_mcp.py), so src/kiro_crew/acp/mcp_session_report.py is 1,586 lines, under the 1,600 at which a file is split.

Review round 5 (head fc01a4588a), the one finding and what changed:

  • Opus: on a host whose registry drops one of the agent's own servers, that server never reports, so the first prompt held the full 5 s although the block already says what is true of it.
  • This was the fourth finding of one class (which servers a first prompt is told of, and waits for), so the class is closed by construction instead of by a fifth case. One function, 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.
  • A table-driven test runs every state of the vocabulary for a server the start skipped and for one it did not (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.
  • Tests that say "this prompt does not hold" are now bounded far below the hold's cap, so a hold that wrongly waits fails by name instead of ending at its cap.
  • Docs that describe what this change touches now say so: the control owners table, the two liveness sentences and the keepalive route's contract in the specs, and for users the agent.tool_search row 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:

  • GPT: two tests in test/test_mcp_servers_block.py compared 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.
  • Every other lane and every test shard, Linux and Windows, passed on that head. No source file changed in this round.

Review round 7 (head 010f4c98de), the one finding and what changed:

  • GPT, upheld on the rule that a bound's overflow is counted and said: a status snapshot longer than the 256 entries the report reads was cut by position and not counted, so a server whose entry was cut read as still starting and mcp_server_wait waited 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).
  • A report that left a name out is partial: only a server the host lists as starting is called still starting, never one that merely has no report; no first prompt counts as told, so it holds as any untold prompt does; the block says once how many servers are not tracked; mcp_server_wait answers 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.py is 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, model claude-fable-5.2, one run per cell.

Case OS Default backend, before Default backend, after Kiro CLI pick, before Kiro CLI pick, after
1. A fast server's tool on the first prompt Linux PASS PASS PASS PASS
2. A server still loading (25 s) on the first prompt: says so, waits, calls it, completes Linux FAIL PASS FAIL PASS
3. The same server on a later prompt, once connected Linux PASS PASS PASS PASS
4. A server that fails to start: reported as failed, the others work Linux PASS PASS PASS PASS
5. A server that needs a sign-in: reported as that, not as loading Linux PASS PASS PASS PASS
6. A disabled server: not started, not shown as loading Linux PASS PASS PASS PASS
7. A remote (HTTP) server and a stdio server Linux PASS PASS PASS PASS
8. A chat closed and reopened: its tools work again Linux PASS PASS PASS PASS
9. An asking mode: an MCP tool that is not approved ahead of time raises its approval card Linux PASS PASS PASS PASS
10. Tool Search off: cases 1 and 2 Linux PASS PASS PASS PASS
11. 30 servers: all connected within 90 s, same tool names, a real call to the last Linux PASS (13 s) PASS (12 s) PASS PASS
12. Kiro Crew's own tools: same names listed, one call of each server answers Linux PASS PASS (one more name: mcp_server_wait) PASS PASS
  • Case 2, before, default backend: the reply carried the code after 7 tool calls (config files read, a shell sleep) and never said the server was loading, which is what the case asks for. After: "The late-tools server is still starting, so I will wait for it. The code is LATE-7391-OK-7BF6." Tool calls in order: mcp_server_wait, the loader, late_lookup.
  • Case 9: a user's own server is approved ahead of time in the agent Kiro Crew writes, on both builds, so its tool raises no card in any mode; the case therefore calls cron_add, which is not.
  • The table above was made before the review rounds. The twelve cases were run again on the round-3 code and on the two other systems:
OS Build Kiro CLI, engine Default backend Kiro CLI pick
Linux 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) 3.2.0, 3.2.0 12 of 12 PASS 12 of 12 PASS
macOS 963821ca49 (round 2), main 5f48319 before 3.2.1, v3 13 of 13 PASS. Case 2: FAIL twice before, PASS 3 of 3 after 12 of 13 in the full run: case 5 failed, the reply was right and the check read it as a guess; its re-run passed. Case 2: FAIL twice before, PASS 3 of 3 after
Windows 3ef637f597 (round 5), main 5f48319 before; cases 2 and 11 again on 010f4c98de (same source) 3.2.0, 3.2.0 Cases 1, 2, 10, 11 at 30 and 64 servers, 12: all PASS; case 2 PASS 3 of 3 (before: FAIL in every run). 100 of the user's servers, n = 5: the first prompt went out without the hold 5 of 5, its block named 98 to 100 of them, and the first token came at 9.0 s against 14.0 s on this head's own base The same cases all PASS; case 2 PASS 3 of 3 (before: FAIL in every run)
  • macOS and Windows run thirteen cases: the 64-server case is not run on the shared Linux host. On both, 64 servers were all connected in 16 to 19 s with the same tool names, and a real call to the last one answered.
  • macOS and Windows are run again on the pushed head by their own runners; no case is known to be unable to run on an OS. The Windows row above is a confirmation run of cases 1, 2, 10, 11 and 12, with the 100-server first prompt added.
  • On the pushed head 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).
  • Seen on macOS and not asked for: with a fast server on the first prompt (case 1) the model now sometimes says it is still starting and calls mcp_server_wait first; 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:

User servers Prompt Before After
30 first 15.12, 18.94, 20.78 9.53, 9.68
30 second 5.45, 4.98, 4.61 5.60, 5.12
30 third 4.33, 4.42, 4.45 4.59, 4.39
10, sent 3 s after the chat opened first 13.29, 12.00, 12.96 7.97, 8.15, 14.05
10, sent at once first not measured (the gateway did not start) 9.52, 10.07, 10.00
  • The first prompt at 30 servers, split: the wait for the session was 9.40, 10.15, 14.85 before and 4.45, 5.35 after; the wait for the model was 5.14, 8.61, 5.68 before and 4.48, 4.08 after. session/new took 7.58, 7.94, 8.89 before and 2.55, 3.46 after.
  • The third "after" run at 30 servers is left out: the host was under memory pressure during it.
  • Not measured: 64 servers (not run on the shared Linux host), Kiro CLI beside these cells, and these cells on the pushed head.

The same on macOS (Mac mini M2), where 64 servers can be run: main 5f48319 against 963821ca49, default backend, kiro-cli 3.2.1 with the v3 engine on both, median of 5 new chats, first prompt sent at once, seconds:

User servers Time to first text, before -> after Everything but the model wait, before -> after Model wait, before -> after Kiro CLI, first text Kiro CLI, model wait
0 5.92 -> 6.74 2.51 -> 2.39 3.58 -> 4.36 4.36 3.22
10 8.54 -> 7.78 4.44 -> 3.06 3.83 -> 4.76 4.52 3.35
30 12.62 -> 7.90 8.59 -> 3.19 4.07 -> 4.80 4.75 3.54
64 14.53 -> 9.56 9.96 -> 3.48 4.67 -> 6.10 4.40 3.21
  • Read the model wait with care: the two builds were measured two to three hours apart and the provider was slower in the later hour. With no server at all, where this change does nothing, the model wait is 3.58 s before and 4.36 s after.
  • The second prompt, sent the moment the first reply ends: first text 3.49 -> 4.36 s at 10 servers, 3.80 -> 5.73 s at 30, 5.48 -> 8.00 s at 64 (0 servers: 3.59 -> 4.10 s, the slower hour again). After this change that moment comes while servers are still connecting.
  • Prompts two and three against a fourth prompt of the same chat sent once every server had settled, at 64 servers: after this change prompt two costs 1.3 to 1.8 s more and prompt three 1.0 s more; before it prompt two costs 0.6 to 1.6 s more and prompt three nothing. So this change takes about 5 s off the time to first text of the first prompt at 30 and 64 servers (5.4 and 6.5 s off everything but the model wait) and adds about 1 s to the third. At 0, 10 and 30 servers nothing can be told apart from the provider's spread.

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

  • At most two commits (one is the norm), with a Conventional Commits title (feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)
  • Existing tests pass and new tests added for new functionality
  • Self-review completed; code follows project style guidelines
  • Documentation updated (if applicable)
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributions are accepted under the project's Apache-2.0 license; see the Licensing section of CONTRIBUTING.md.

@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 12, 2026 02:46
@bolichen97
bolichen97 requested a review from CrysisDeu November 12, 2026 02:46
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 12, 2026
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 32d630670efded34ed3a58fce6fb5d9e24d8dfb6 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

Design-level review of 32d630670efded34ed3a58fce6fb5d9e24d8dfb6 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks. Folding each MCP frame as it arrives, and not holding the prompt when its [MCP SERVERS] block names every late server, fixes the slow first prompt and the "missing server" error at their source.

Notes

  • turn_is_told decides whether to hold by looking for the block's mark inside the prompt text. That ties the transport to how the context is assembled. If the mark is missing, the prompt holds up to 5 s as it did before, so nothing breaks, but a change to how the block is built would quietly bring the delay back.
  • The description is cut off before ## Backwards compatibility. mounted_servers was removed, and no reader of it is left in the tree. The drain-time fold tests were swapped for forget_reported mark tests, which replace the mechanism without reversing a pinned behaviour.

[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 .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@bolichen97
bolichen97 enabled auto-merge (squash) November 12, 2026 02:48
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 32d630670efded34ed3a58fce6fb5d9e24d8dfb6 — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

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

  • Item 7 — oversized: MCP_STATUS_CAP = 256 is "four times the largest set measured (64 of the user's servers…)". Even so, the new model-facing surface spends text on sessions above that bound: the _NOT_TRACKED row in context_assembly/mcp_servers.py, plus mcp_reports_left_out / _UNKNOWN_LEFT_OUT in the wait tool. The visible description never mentions them.
    Subtraction: delete the _NOT_TRACKED row and its told-record, TurnMcpStatesReader.not_tracked, mcp_reports_left_out and _UNKNOWN_LEFT_OUT. Keep only the left_omitted/left_out hold in turn_is_told, which keeps the prompt from going out untold.
    Clears when: the mechanism is removed, or a human amends the Goal.

What this change ships

Inventory (10 items) — 8 justified

Intent: 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.

  1. A dashboard chat's first prompt no longer waits up to 5 s for the user's own MCP servers — justified
  2. A first prompt without the block (kirocrew chat, one-shots, commands) holds up to 5 s, at the turn instead of at session start — justified
  3. A session's MCP report, and the chat's MCP panel, update as frames arrive, during and between turns — justified
  4. New [MCP SERVERS] context block names servers that are starting, failed, need a sign-in or are switched off — justified
  5. New mcp_server_wait tool on every shipped agent — justified
  6. The keepalive route answers an mcp_server state query for the calling session — justified
  7. Status cap raised from 64 to 256, with counts of what was left out shown to the model as a "not tracked" row and as wait-tool text — undeclared, oversized
  8. A mode switch forgets earlier server reports — justified
  9. Conductor token budgets raised to 7,700/7,850 — justified
  10. The wait tool matches a server name regardless of case — undeclared

[FIRST-PRINCIPLES-REVIEWED] 32d6306

Description read

[DESCRIPTION-READ] 72c454eb042b774f2497bf768a2cf6697f047c0992616647b31887de0cf77bfe

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 32d630670efded34ed3a58fce6fb5d9e24d8dfb6 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 32d6306

Verdict parsed from the review's SHA-scoped output markers for commit 32d630670efded34ed3a58fce6fb5d9e24d8dfb6.

False positive or not applicable? A repository writer can comment:
/ai-review override fable 32d630670efded34ed3a58fce6fb5d9e24d8dfb6 false-positive: <reason, 20 to 500 characters>

@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 32d630670efded34ed3a58fce6fb5d9e24d8dfb6 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 32d6306

False positive or not applicable? A repository writer can comment:
/ai-review override gpt 32d630670efded34ed3a58fce6fb5d9e24d8dfb6 false-positive: <reason, 20 to 500 characters>

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@bolichen97
bolichen97 force-pushed the fix/live-mcp-session-report branch from 259739a to 6a43634 Compare November 12, 2026 03:28
@github-actions

github-actions Bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

Sensitive Change Review

Sensitive files changed:

  • src/kiro_crew/security_posture.py

  • @bolichen97 posted a complete reasoning template for 32d6306.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 12, 2026

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@bolichen97
bolichen97 force-pushed the fix/live-mcp-session-report branch from 6a43634 to 963821c Compare November 12, 2026 04:57
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 963821c
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one entry, mcp_tools/control_parts/mcp_wait.py. No redactor, tool gate, sandbox rule, deny rule or scan exemption changes.
  • Before -> after (what was allowed/blocked, now): Before, the module did not exist. After, the new mcp_server_wait tool handler, which passes a server name through redact_exfiltration_urls and redact_credentials before it reads the name back in its tool result, is classified as "calls a redactor, is not an egress boundary", beside its sibling tool handler mcp_tools/control_parts/monitor.py and for the reason the comment above that entry gives (a tool result's user-visible surface is a registered sink downstream). Nothing that was blocked is now allowed, and nothing that was redacted stops being redacted.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of output boundaries leaves out one module that should have been counted as a sink. No secret path opens: the module still redacts, and its output still passes the registered tool-result sink.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox or gate rule changes. The evidence is the posture census itself: test/test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted failed on the first pushed head with this module unclassified and passes with the entry.
  • No regression:
    • Tools still work (which tools/commands were run, result): the MCP smoke test on Linux, default backend and the Kiro CLI pick, 12 cases each with real tool calls, including mcp_server_wait itself: 12 of 12 pass. It ran on this diff before the review-round fixes; the table is in the PR description.
    • Backward compatible (old config / old data / old callers still work, how checked): the set is additive; no config key, stored data or caller reads it besides the posture panel and its test.
    • Existing tests (which suites passed on this head): on 4a678701b5, the same two commits one main commit earlier (git range-diff shows both as =; the commit in between changes only files under website/): the 27 test files this diff changes plus test_security_posture.py, test_flake_pattern_ratchet.py, test_facade_mirror_guards.py, test_pid_lifecycle_teardown.py and test_acp_usage_cost.py, 2,269 passed; mypy, flake8, isort, black, the line cap, comment-history and brand checks returned 0. They were not re-run locally on 963821ca49; CI runs on it.
  • How to undo: delete the one added line. The posture test then fails until mcp_wait.py no longer calls a redactor.

@KiroCrewCaptain

KiroCrewCaptain commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: A person should decide

Why: 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 32d630670e · 6088 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@buluoray buluoray left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
@buluoray
buluoray dismissed stale reviews from themself November 12, 2026 05:50

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.

@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 9ff798f
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one entry, mcp_tools/control_parts/mcp_wait.py. No redactor, tool gate, sandbox rule, deny rule or scan exemption changes. This is the same one-line change as on the last head; this push did not touch the file (it changed how the session's MCP report bounds its lists).
  • Before -> after (what was allowed/blocked, now): Before, the module did not exist. After, the new mcp_server_wait tool handler, which passes a server name through redact_exfiltration_urls and redact_credentials before it reads the name back in its tool result, is classified as "calls a redactor, is not an egress boundary", beside its sibling tool handler mcp_tools/control_parts/monitor.py and for the reason the comment above that entry gives (a tool result's user-visible surface is a registered sink downstream). Nothing that was blocked is now allowed, and nothing that was redacted stops being redacted.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of output boundaries leaves out one module that should have been counted as a sink. No secret path opens: the module still redacts, and its output still passes the registered tool-result sink.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox or gate rule changes. The evidence is the posture census itself: test/test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted failed on the first pushed head with this module unclassified and passes with the entry.
  • No regression:
    • Tools still work (which tools/commands were run, result): the MCP smoke test on Linux, default backend and the Kiro CLI pick, 12 cases each with real tool calls, including mcp_server_wait itself: 12 of 12 pass on both. It ran on fb4f71190d, this head's two commits on an earlier main (one test line differs: a value the rebase recomputed).
    • Backward compatible (old config / old data / old callers still work, how checked): the set is additive; no config key, stored data or caller reads it besides the posture panel and its test.
    • Existing tests (which suites passed on this head): on this head 9ff798f02a, the 42 test files this diff touches or pins, test_security_posture.py among them, 2,755 passed; mypy, flake8, isort, black, the line cap, docs lint, comment-history, brand and harness-parity checks returned 0.
  • How to undo: delete the one added line. The posture test then fails until mcp_wait.py no longer calls a redactor.

@github-actions github-actions Bot added merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: action required A blocking check or review needs attention and removed merge conflict Branch has merge conflicts with its base — author must resolve before merge readiness: checking Automated validation is still running labels Nov 12, 2026
@bolichen97
bolichen97 force-pushed the fix/live-mcp-session-report branch from 9ff798f to a4b4a6c Compare November 12, 2026 19:15
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge labels Nov 12, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: a4b4a6c
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one entry, mcp_tools/control_parts/mcp_wait.py. No redactor, tool gate, sandbox rule, deny rule or scan exemption changes. This is the same one-line change as on the last head; this push is a rebase onto main and did not touch the file.
  • Before -> after (what was allowed/blocked, now): Before, the module did not exist. After, the new mcp_server_wait tool handler, which passes a server name through redact_exfiltration_urls and redact_credentials before it reads the name back in its tool result, is classified as "calls a redactor, is not an egress boundary", beside its sibling tool handler mcp_tools/control_parts/monitor.py and for the reason the comment above that entry gives (a tool result's user-visible surface is a registered sink downstream). Nothing that was blocked is now allowed, and nothing that was redacted stops being redacted.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of output boundaries leaves out one module that should have been counted as a sink. No secret path opens: the module still redacts, and its output still passes the registered tool-result sink.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox or gate rule changes. The evidence is the posture census itself: test/test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted failed on the first pushed head with this module unclassified and passes with the entry.
  • No regression:
    • Tools still work (which tools/commands were run, result): the MCP smoke test on Linux, default backend and the Kiro CLI pick, 12 cases each with real tool calls, including mcp_server_wait itself: 12 of 12 pass on both. It ran on fb4f71190d, this head's two commits on an earlier main (one test line differs: a value the rebase recomputed).
    • Backward compatible (old config / old data / old callers still work, how checked): the set is additive; no config key, stored data or caller reads it besides the posture panel and its test.
    • Existing tests (which suites passed on this head): on this head a4b4a6c4ab, the 42 test files this diff touches or pins, test_security_posture.py among them, 2,755 passed; mypy, flake8, isort, black, the line cap, docs lint, comment-history, brand and harness-parity checks returned 0.
  • How to undo: delete the one added line. The posture test then fails until mcp_wait.py no longer calls a redactor.

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 12, 2026
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.
@bolichen97
bolichen97 force-pushed the fix/live-mcp-session-report branch from a4b4a6c to 32d6306 Compare November 12, 2026 20:36
@github-actions github-actions Bot added readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 12, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 32d6306
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one entry, mcp_tools/control_parts/mcp_wait.py. No redactor, tool gate, sandbox rule, deny rule or scan exemption changes. This is the same one-line change as on the last head; this push is a rebase onto main plus one line of a doc page, and did not touch the file.
  • Before -> after (what was allowed/blocked, now): Before, the module did not exist. After, the new mcp_server_wait tool handler, which passes a server name through redact_exfiltration_urls and redact_credentials before it reads the name back in its tool result, is classified as "calls a redactor, is not an egress boundary", beside its sibling tool handler mcp_tools/control_parts/monitor.py and for the reason the comment above that entry gives (a tool result's user-visible surface is a registered sink downstream). Nothing that was blocked is now allowed, and nothing that was redacted stops being redacted.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): the security posture panel's count of output boundaries leaves out one module that should have been counted as a sink. No secret path opens: the module still redacts, and its output still passes the registered tool-result sink.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox or gate rule changes. The evidence is the posture census itself: test/test_security_posture.py::TestOmissionDetection::test_every_redactor_call_site_is_a_registered_sink_or_allowlisted failed on the first pushed head with this module unclassified and passes with the entry.
  • No regression:
    • Tools still work (which tools/commands were run, result): the MCP smoke test on Linux, default backend and the Kiro CLI pick, 12 cases each with real tool calls, including mcp_server_wait itself: 12 of 12 pass on both. It ran on fb4f71190d, this head's two commits on an earlier main (one test line differs: a value the rebase recomputed).
    • Backward compatible (old config / old data / old callers still work, how checked): the set is additive; no config key, stored data or caller reads it besides the posture panel and its test.
    • Existing tests (which suites passed on this head): on this head 32d630670e, the 49 test files this diff touches or pins, test_security_posture.py among them, 2,898 passed; mypy, flake8, isort, black, the line cap, docs lint, comment-history, brand and harness-parity checks returned 0.
  • How to undo: delete the one added line. The posture test then fails until mcp_wait.py no longer calls a redactor.

@github-actions github-actions Bot added readiness: passed Eligible automated validation passed for the current revision and removed readiness: checking Automated validation is still running labels Nov 12, 2026

@KiroCrewCaptain KiroCrewCaptain left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 = 0 reset 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.

@bolichen97
bolichen97 merged commit bc6534a into main Nov 12, 2026
107 of 110 checks passed
@bolichen97
bolichen97 deleted the fix/live-mcp-session-report branch November 12, 2026 22:33
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants