Skip to content

perf: list MCP tools before loading tool handlers - #35293

Merged
bolichen97 merged 1 commit into
mainfrom
perf/cold-session-start
Nov 12, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
perf/cold-session-start

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A new session stops waiting for Kiro Crew's own MCP servers to load their tool code before they can say which tools exist.

The agent engine starts every MCP server of a session when the session starts, and holds the first prompt until each has answered initialize and tools/list. Kiro Crew's four own servers (kirocrew-core, kirocrew-cron, kirocrew-guide, kirocrew-mate) each imported about 1,000 package modules before answering: the code that runs every tool, the sub-agent manager, the conversation store, the agent client. On a zero-config Linux install the slowest of them, kirocrew-core, took about 1.4 s to list, and the session could not start before it.

Why it matters

Every new session pays this, on every backend, before the user's first message is even sent to the model. It is the largest part of the gap between Kiro Crew's cold session start and the bare engine's.

Not a goal

  • No cached, precomputed or gateway-written tool list. There is one listing path, and it is live.
  • No change to which tools a session sees, or to any description. The lists are byte-identical.
  • No change to how the gateway places or waits for MCP servers (acp/ is untouched).
  • No shared or pooled server by default, and no warm pool.
  • No change to any security rule, sandbox scope or policy read.
  • The engine's own boot time.

What changed (motivation → approach → change)

A new session starts sooner, with the same tools. Each of Kiro Crew's own MCP servers now says which tools it has first, and loads the code that runs them after.

Before After
The server imports its handlers, then answers The server answers, then imports its handlers
Two places built the initialize result and the filtered list inside the dispatch loop One function builds each (mcp_shared_listing), used before and after the handlers load
Each server passed its loop options by hand Each server declares itself once (StdioServer), in a module that imports no handler

Why this shape. Listing needs the tool descriptors and the session's tool policy. It does not need the code that runs a tool. So the descriptors moved to modules that import no handler (mcp_tools/catalog/, and the *_tool_list module of each server), and mcp_entry answers the two requests once the platform has booted. Every start-up refusal still happens before anything is answered. A tools/call that arrives while the handlers load waits in the pipe; the loop then handles every frame once, in order.

The two live hints stay live. The spawn tools' descriptions name the sub-agent ceiling and the agents the calling parent may spawn. Their readers now work before kiro_crew.subagent and the conversation store are loaded: subagent_parts/host_memory.py and the new subagent_parts/spawn_allowlists.py import what they read, kiro_crew.subagent_standalone reaches them, and history_metadata_line.py reads one session's record without the store, from the file ConversationLog._path resolves (that method is unchanged). Once those modules are loaded the same calls go through them, so every existing patch seam still works.

If the handlers cannot load. The import runs where it always ran. A missing dependency still heals and retries. Any other failure still prints its reason on stderr and exits non-zero. The difference is timing: the client already holds the tool list, so it sees a server that listed its tools and then closed its pipe, the same state as a server that crashed mid-session.

Smaller cuts on the same path. Platform boot and core's listing no longer load the OS sandbox module (two constants and two phrases moved to light modules: speech_providers, autonudge_judge_phrases). The config loader imports the MCP rewriter only on the branch that reads it (config/loader.py, config/loader_config.py), and messaging/__init__.py resolves its exports on first read.

A ratchet holds it. test_mcp_listing_import_budget.py runs each server's real entry in a fresh interpreter and bounds what is loaded when the list goes out: a named denylist and a module count per server.

Time from spawn to tools/list answered, the four servers started together as the engine starts them. Linux, one host, n = 3 before and n = 3 after, taken in before/after pairs, one measurement at a time; before = main at the merge-base. Median, with the three samples in brackets:

Server Before After
kirocrew-guide 1754 ms (1104, 1754, 1755) 608 ms (528, 608, 856)
kirocrew-mate 1753 ms (1111, 1753, 1753) 611 ms (563, 611, 855)
kirocrew-cron 1772 ms (1132, 1772, 1772) 623 ms (545, 623, 888)
kirocrew-core 2208 ms (1402, 2208, 2220) 898 ms (731, 898, 1138)
all four listed 2220 ms (1414, 2220, 2233) 906 ms (739, 906, 1145)

The host was shared (1-minute load 0.35 to 0.73 per core), which is why the samples spread; within each pair the after run took 41% to 52% of the before run. This phase ends before the model is called, so no model turn was timed. Package modules loaded at list time: about 1,000 before; 461 (core) and about 330 (the other three) after.

The design note (one listing path, no handoff file, live hints kept) was reviewed by a maintainer before the build; the diff is large because descriptors moved, not because behaviour grew.

Backwards compatibility

Compatible: every server answers the same initialize result and the same tool list, byte for byte (compared for all four against main), and every import path and patch seam that existed still resolves.

Removes nothing for a caller: each definition below moved to a new module, and the module it left still serves the same name as the same object. The readers, found by git grep on origin/main:

Reader: src/kiro_crew/mcp_tools/init.py:build_tool_list -- chat -- reads each domain's schemas() and advertised() from mcp_tools/catalog/<domain>, the module that now defines them; test_mcp_tool_registry.py
Reader: src/kiro_crew/mcp_tools/init.py:build_tool_names -- chat -- the same builders, names only; test_mcp_discovery_agent_config.py
Reader: src/kiro_crew/mcp_tools/app_tools.py:_core_tool_names -- app -- moved with schemas() into mcp_tools/catalog/app_tools.py and reads the catalogue; test_app_agent_tools.py
Reader: src/kiro_crew/apps/builtins/ops_mission_control/tests/test_agent_api_tool.py:app_tools.schemas -- app -- mcp_tools/app_tools.py re-exports schemas and advertised from the catalogue
Reader: src/kiro_crew/mcp_tools/control_parts/monitor.py:screen_phrase -- chat -- autonudge_judge.py re-exports screen_phrase and ending_phrase from autonudge_judge_phrases.py
Reader: src/kiro_crew/dashboard/session_directive_apply_monitor.py:screen_phrase -- chat -- the same re-export; test_campaign_facades_base_public_names.py
Reader: src/kiro_crew/mcp_tools/control_parts/schemas.py:ending_phrase -- chat -- imports both phrases from autonudge_judge_phrases.py, the same objects
Reader: src/kiro_crew/mcp_tools/spawn_parts/listing.py:visible_agent_names -- subagent -- imported from kiro_crew.subagent, which binds it from subagent_parts/spawn_allowlists.py; test_agent_roster_shared.py
Reader: src/kiro_crew/mcp_tools/spawn.py:agent_matches_allowlist -- subagent -- imported from kiro_crew.subagent, as is parent_spawn_allowlists; test_spawn_parts_contract.py
Reader: src/kiro_crew/subagent_parts/agent_policy.py:_vet_parent_available_agents -- subagent -- runs on the facade's globals, where the four moved names stay bound; test_spawn_parent_available_agents.py
Reader: src/kiro_crew/acp/kas_subagent_targets.py:spawn_allowlist -- subagent -- imported from kiro_crew.subagent; test_subagent_parts_composition_contract.py holds it as one object
Reader: src/kiro_crew/agent_sdk/tools_settings_reach.py:spawn_allowlist -- chat -- names the function in its docstring only; the reference now points at spawn_allowlists.py
Reader: src/kiro_crew/slack/gateway_runtime/cron_fire.py:parent_spawn_allowlists -- cron -- imported from kiro_crew.subagent, unchanged

The security posture table gains one row: subagent_parts/spawn_allowlists.py sits beside subagent_parts/agent_policy.py in NON_EGRESS_REDACTION_MODULES (security_posture.py), because the two redactor calls it holds moved from that file unchanged. No output path is added.

Where the code went, by file:

  • Listing owner and loop: mcp_shared_listing.py (new), mcp_shared.py, mcp_shared_dispatch.py, mcp_shared_wire.py, mcp_entry.py.
  • Server declarations: mcp_core_tool_list.py, mcp_guide_tool_list.py, mcp_mate_tool_list.py (new), mcp_cron_tool_list.py; their servers mcp_core.py, mcp_cron.py, mcp_guide.py, mcp_mate.py pass the declaration to the loop.
  • Descriptors: src/kiro_crew/mcp_tools/catalog/ (new); each domain module under src/kiro_crew/mcp_tools/ re-exports its builders.
  • Live hint readers: subagent_standalone.py (new), subagent.py and subagent_parts/; execution_context.py, history_metadata_line.py (new), history.py, history_projection.py, history_projection_contract.py, history_projection_reads.py.
  • Sandbox off the path: speech_providers.py, voice_reply.py, autonudge_judge.py, autonudge_judge_phrases.py (new).
  • One follow-on in src/kiro_crew/mcp_gateway/pool.py, below.

One behaviour changes for an operator who set either of two config keys. mcp_gateway/pool.py resolves mcp_gateway.read_buffer_limit_bytes and mcp_gateway.response_spill_threshold_bytes while it is imported. On main that read ran inside the config loader's own import, failed every time, and was swallowed, so the gateway side used the environment variable or the built-in default and ignored the key. The loader no longer imports the MCP rewriter eagerly, so the read now succeeds and a configured value is the one in force, as docs/architecture/mcp.md already describes. Unset keys (the default) read exactly as before. With no data home yet the import reads no config and creates nothing, as before (test_mcp_gateway_oversize.py).

Tests

  • test/test_mcp_shared_listing.py (new): the two builders; the early answers take only the two requests they serve; a call, a malformed frame, an end of stream and a failed list are left for the loop; the loop answers what was left once and in order; a later list comes from the same function.
  • test/test_mcp_listing_import_budget.py (new): the ratchet described above, in a real subprocess per server.
  • test/test_history_metadata_line.py (new): the light reader and the store agree on every first-line shape; the session record is read without loading the store.
  • test/test_subagent_standalone.py (new): the two standalone owners bind every global they read, answer with the facade unloaded, and a patch of the facade reaches them once it loads.
  • Contract tests updated for the moved definitions: test_subagent_parts_composition_contract.py, test_spawn_parts_contract.py, test_mcp_shared_facade.py, one inventory file, and the source-path pins that named the old files (test_agent_spec_hardened_reads.py, test_agent_spec_pins.py, test_kas_tools_settings_aliases.py, test_crewmate_prompts.py, test_agent_refactor_contracts.py).
  • test/test_mcp_gateway_oversize.py: importing the gateway with no data home creates nothing and uses the defaults; with a configured ceiling, that ceiling is in force.

Determinism: the four new files ran 10 times at -n 2 with 0 failures, and once in a shuffled order (seed 20261111, -n0), all passing. No test sleeps or waits on a literal duration; the silent-client case is scripted, so no time passes.

Related sets run locally by name (2,067 tests across 37 files, plus the roster and spawn files), all passing. isort, flake8, mypy, the black gate, the comment-history, brand, line-cap, subprocess-encoding and harness-parity gates, the flake-pattern ratchet and the repository's semgrep rules pass.

Manual verification

  • All four servers: initialize result and tool list compared byte for byte against main at the merge-base (134,440 bytes for core). Identical.
  • A full first prompt through a gateway was not re-run on this final diff: the phase this change moves ends before the model is called, so it was timed on its own (table above). The end-to-end figure comes from the integrated run of the full harness.
  • Still to do by hand: watch what the engine shows when a server's handlers fail to load after it has listed. The server side (stderr reason, non-zero exit) is unchanged and covered by the entry's existing tests.

Screenshots / video

N/A. No user-visible frontend surface is touched.

Related Issues

Closes #35275

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

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

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 297b0167a1d3e3d3142a9a24048eb3fed00be86c 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 11, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: every server still lists its tools through one live path, and the remaining handler-load failure is described and accepted.

Notes

  • mcp_gateway/pool.py now skips config reads at import when no data home exists. The visible description never mentions this change; add it to "Smaller cuts", or move it to its own PR.
  • The description is cut off inside ## Backwards compatibility, so I could only check the Reader lines before the cut.

[DESIGN-REVIEWED] 297b016

Description read

[DESCRIPTION-READ] 524fb1c0201f32c701811bf872a7e6957a170bdca9d19a46bf8630d6fc768438

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.

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 297b0167a1d3e3d3142a9a24048eb3fed00be86c — 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: each item lowers the measured spawn-to-list time and leaves both answers byte-identical. If the engine never sends tools/list, the cost is a wait of at most 1 s, and sessions still start.

Notes

  • Item 7 — rides along: mcp_gateway/pool.py adds _config_readable_at_import, justified as "importing the gateway must create nothing". That is not part of the Goal ("stops waiting for Kiro Crew's own MCP servers to load their tool code"), and the visible description gives it no listing-path cost. Subtraction: drop _READ_CONFIG_AT_IMPORT, the read_config parameter and TestCeilingsResolvedAtImport, or show that the listing path imports pool.

What this change ships

Inventory (8 items) — 7 justified

Intent: a new session starts sooner because Kiro Crew's four MCP servers list their tools before loading their handlers. ADDITION (perf).

  1. The core, cron, guide and mate servers answer initialize/tools/list before importing their handlers — justified
  2. A tools/call sent during handler load waits, then is handled in order — justified
  3. A handler-load failure now shows up after the tool list went out, not before — justified
  4. Each server declares one StdioServer, used by both the early answer and the loop — justified
  5. Tool descriptors moved into handler-free mcp_tools/catalog/ and *_tool_list modules — justified
  6. Spawn hints and the session record are read without loading the subagent manager or conversation store — justified
  7. Importing the gateway pool on a host with no data home skips config and creates nothing — rides along
  8. An import-budget ratchet caps the modules each server loads by the time it has listed — justified

[FIRST-PRINCIPLES-REVIEWED] 297b016

Description read

[DESCRIPTION-READ] 3d3e1e5489239f25a08b6bb7033998d25fb656f22d0a1ff462ef92df1a97324c

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 11, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 297b0167a1d3e3d3142a9a24048eb3fed00be86c and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 297b016

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

@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

Reviewed 297b0167a1d3e3d3142a9a24048eb3fed00be86c — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 297b016

Verdict parsed from the review's SHA-scoped output markers for commit 297b0167a1d3e3d3142a9a24048eb3fed00be86c.

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

@bolichen97
bolichen97 force-pushed the perf/cold-session-start branch from b50a3b4 to 0755a3c Compare November 11, 2026 13:30
@github-actions

github-actions Bot commented Nov 11, 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 297b016.

@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 0755a3c
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one row, subagent_parts/spawn_allowlists.py. Nothing else in a sensitive path changed.
  • Before -> after (what was allowed/blocked, now): Nothing is allowed or blocked differently. The set records which modules that call a redactor are NOT output boundaries; only the security posture panel's sink count and test_security_posture.py read it, no redactor does. Before, subagent_parts/agent_policy.py (already in the set) held 8 redact_via_context calls. After, it holds 6 and the new owner holds the other 2, moved unchanged: the roster names in visible_agent_names and the parent template name in _surface_unresolved_parent_spec. The new row sits beside the old one for that reason.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): If this module were in fact an output boundary, the posture panel would under-count redaction sinks by one. No secret leaks and no command breaks from the row itself: both calls still redact exactly as they did, and the module opens no transport and adds no audience.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox rule, seal, mask or deny pattern is touched. Evidence is the diff: git grep -c "redact_via_context(" origin/main -- src/kiro_crew/subagent_parts/agent_policy.py prints 8; on this head the same count is 6 there and 2 in spawn_allowlists.py, and the two moved functions are byte-identical to main's.
  • No regression:
    • Tools still work (which tools/commands were run, result): initialize and tools/list of all four Kiro Crew MCP servers compared byte for byte against main at the merge-base: identical. The spawn roster hint and spawn_list tests pass (test_agent_roster_shared.py, test_spawn_agent_roster.py, test_spawn_parent_available_agents.py).
    • Backward compatible (old config / old data / old callers still work, how checked): No config or data shape changes. Every caller still imports the four moved names from kiro_crew.subagent; test_subagent_parts_composition_contract.py holds each as one object with its old signature.
    • Existing tests (which suites passed on this head): locally on this head, test_security_posture.py, test_subagent_standalone.py, test_mcp_listing_import_budget.py and test_history_metadata_line.py (97 passed). The row was added because CI's Static Ratchet Gate was red without it on the previous head; CI on this head is still running.
  • How to undo: revert this PR. The row cannot be dropped alone: test_security_posture.py fails while spawn_allowlists.py calls a redactor without a classification.

@bolichen97
bolichen97 enabled auto-merge (squash) November 11, 2026 13:48
@KiroCrewCaptain

KiroCrewCaptain commented Nov 11, 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 an 18% chance that this change introduces a defect, above the 12% limit for approving on its own.

The four Kiro Crew stdio servers now answer initialize and tools/list before importing their tool handlers. Both answers come from one builder (mcp_shared_listing), which the dispatch loop also uses. Frames the early path doesn't answer are handed to the loop in order, from the same stdin buffer or Windows pump, so nothing is lost or answered twice. The loop still reads the inflight capability from the early initialize. Startup refusals (root run, platform boot) still happen before any answer, and the heal-and-retry path stays idempotent. The core pickup redeem resolves the port the same way as before. The light session-record reader resolves the same file and parse rules as the store. The moved allowlist owner binds the same names the facade does, and patch seams are kept through loaded_binding. Tests cover the listing module, a real-subprocess import budget, the record reader and the standalone sub-agent readers, and docs are updated. The one disclosed behaviour change, gateway config keys now being honoured, matches the docs and has a test.

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 297b0167a1 · 10894 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

Comment thread src/kiro_crew/history_files.py Fixed
Comment thread src/kiro_crew/history_files.py Fixed
@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 11, 2026
@bolichen97
bolichen97 force-pushed the perf/cold-session-start branch from 0755a3c to 337a393 Compare November 11, 2026 14: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 11, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 337a393
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one row, subagent_parts/spawn_allowlists.py. Nothing else in a sensitive path changed. Same row as on the previous head; this comment re-states it for the new one.
  • Before -> after (what was allowed/blocked, now): Nothing is allowed or blocked differently. The set records which modules that call a redactor are NOT output boundaries; only the security posture panel's sink count and test_security_posture.py read it, no redactor does. Before, subagent_parts/agent_policy.py (already in the set) held 8 redact_via_context calls. After, it holds 6 and the new owner holds the other 2, moved unchanged: the roster names in visible_agent_names and the parent template name in _surface_unresolved_parent_spec. The new row sits beside the old one for that reason.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): If this module were in fact an output boundary, the posture panel would under-count redaction sinks by one. No secret leaks and no command breaks from the row itself: both calls still redact exactly as they did, and the module opens no transport and adds no audience.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox rule, seal, mask or deny pattern is touched. Evidence is the diff: git grep -c "redact_via_context(" origin/main -- src/kiro_crew/subagent_parts/agent_policy.py prints 8; on this head the same count is 6 there and 2 in spawn_allowlists.py, and the two moved functions are byte-identical to main's.
  • No regression:
    • Tools still work (which tools/commands were run, result): initialize and tools/list of all four Kiro Crew MCP servers were compared byte for byte against main at the merge-base on an earlier head of this branch: identical. The spawn roster hint and spawn_list tests pass (test_agent_roster_shared.py, test_spawn_agent_roster.py, test_spawn_parent_available_agents.py).
    • Backward compatible (old config / old data / old callers still work, how checked): No config or data shape changes from this row. Every caller still imports the four moved names from kiro_crew.subagent; test_subagent_parts_composition_contract.py holds each as one object with its old signature.
    • Existing tests (which suites passed on this head): locally, on this change rebased one main commit earlier, test_security_posture.py, test_subagent_standalone.py, test_subagent_parts_composition_contract.py, test_spawn_parts_contract.py and 16 more named files (946 passed). CI on this exact head is running.
  • How to undo: revert this PR. The row cannot be dropped alone: test_security_posture.py fails while spawn_allowlists.py calls a redactor without a classification.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 11, 2026
@bolichen97
bolichen97 force-pushed the perf/cold-session-start branch from 337a393 to 9e455af Compare November 11, 2026 15:19
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 9e455af
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one row, subagent_parts/spawn_allowlists.py. Nothing else in a sensitive path changed. Same row as on the earlier heads; this comment re-states it for the new one, which only rebased and dropped one row from the black baseline.
  • Before -> after (what was allowed/blocked, now): Nothing is allowed or blocked differently. The set records which modules that call a redactor are NOT output boundaries; only the security posture panel's sink count and test_security_posture.py read it, no redactor does. Before, subagent_parts/agent_policy.py (already in the set) held 8 redact_via_context calls. After, it holds 6 and the new owner holds the other 2, moved unchanged: the roster names in visible_agent_names and the parent template name in _surface_unresolved_parent_spec. The new row sits beside the old one for that reason.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): If this module were in fact an output boundary, the posture panel would under-count redaction sinks by one. No secret leaks and no command breaks from the row itself: both calls still redact exactly as they did, and the module opens no transport and adds no audience.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox rule, seal, mask or deny pattern is touched. Evidence is the diff: git grep -c "redact_via_context(" origin/main -- src/kiro_crew/subagent_parts/agent_policy.py prints 8; on this head the same count is 6 there and 2 in spawn_allowlists.py, and the two moved functions are byte-identical to main's.
  • No regression:
    • Tools still work (which tools/commands were run, result): initialize and tools/list of all four Kiro Crew MCP servers were compared byte for byte against main at the merge-base on an earlier head of this branch: identical. The spawn roster hint and spawn_list tests pass (test_agent_roster_shared.py, test_spawn_agent_roster.py).
    • Backward compatible (old config / old data / old callers still work, how checked): No config or data shape changes from this row. Every caller still imports the four moved names from kiro_crew.subagent; test_subagent_parts_composition_contract.py holds each as one object with its old signature.
    • Existing tests (which suites passed on this head): locally, on this change one main update earlier (main then moved 25 files, none of them touched here), test_security_posture.py, test_subagent_standalone.py, test_subagent_parts_composition_contract.py, test_spawn_parts_contract.py and 23 more named files (1,328 passed). On the previous head CI's Static Ratchet Gate, which runs test_security_posture.py, passed. CI on this exact head is running.
  • How to undo: revert this PR. The row cannot be dropped alone: test_security_posture.py fails while spawn_allowlists.py calls a redactor without a classification.

@github-actions github-actions Bot removed the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 11, 2026
buluoray
buluoray previously approved these changes Nov 11, 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.

Approve on 9e455af. The rebase onto main f859940 drops the graduated black-baseline entry and keeps main's DEFERRED_STEP_WORKERS import beside the PR's two new imports, so lint is green and merge-tree is clean. Backend Tests shards are still running. Lead note: both blockers named at 337a393 are resolved; the delta adds nothing else. Decisive lines: .github/black-baseline.txt (test/test_mcp_gateway_oversize.py removed) ; src/kiro_crew/mcp_tools/spawn.py:929-931 (conflict resolved, all three imports kept) ; src/kiro_crew/mcp_gateway/pool.py:162

@bolichen97
bolichen97 enabled auto-merge (squash) November 11, 2026 21:06
@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 11, 2026
An agent engine starts every MCP server of a session at session start
and holds the first prompt until each has answered initialize and
tools/list. Kiro Crew's four own servers imported about 1,000 package
modules before answering, so a new session waited on code that only a
tool call needs.

Each server now answers both requests once the platform has booted and
loads its handlers after. One function builds each answer
(mcp_shared_listing), used before and after the handlers load, and each
server declares itself once in a module that imports no handler. The
dispatch loop handles every frame the early answers left, once and in
order.

The two live values in the spawn descriptions stay live: their readers
work before kiro_crew.subagent and the conversation store are loaded,
and go through those modules once they are.

A subprocess test bounds what each server may load before it lists.
The tool lists are byte-identical to main.

Closes #35275
@bolichen97

Copy link
Copy Markdown
Contributor Author

Sensitive change review

  • Head commit: 297b016
  • What rule changed: NON_EGRESS_REDACTION_MODULES in src/kiro_crew/security_posture.py gains one row, subagent_parts/spawn_allowlists.py. Nothing else in a sensitive path changed. Same row as on the earlier heads; this comment re-states it for the new one, which rebased onto main and added one test to test/test_subagent_standalone.py; no source file changed since the last head.
  • Before -> after (what was allowed/blocked, now): Nothing is allowed or blocked differently. The set records which modules that call a redactor are NOT output boundaries; only the security posture panel's sink count and test_security_posture.py read it, no redactor does. Before, subagent_parts/agent_policy.py (already in the set) held 8 redact_via_context calls. After, it holds 6 and the new owner holds the other 2, moved unchanged: the roster names in visible_agent_names and the parent template name in _surface_unresolved_parent_spec. The new row sits beside the old one for that reason.
  • Worst case if wrong (breaks commands / leaks secret / locks user out): If this module were in fact an output boundary, the posture panel would under-count redaction sinks by one. No secret leaks and no command breaks from the row itself: both calls still redact exactly as they did, and the module opens no transport and adds no audience.
  • Evidence checked (which sandbox result proves it): N/A for a sandbox result, because no sandbox rule, seal, mask or deny pattern is touched. Evidence is the diff: git grep -c "redact_via_context(" origin/main -- src/kiro_crew/subagent_parts/agent_policy.py prints 8; on this head the same count is 6 there and 2 in spawn_allowlists.py, and the two moved functions are byte-identical to main's.
  • No regression:
    • Tools still work (which tools/commands were run, result): initialize and tools/list of all four Kiro Crew MCP servers were compared byte for byte against main at the merge-base on an earlier head of this branch: identical. The spawn roster hint and spawn_list tests pass (test_agent_roster_shared.py, test_spawn_agent_roster.py).
    • Backward compatible (old config / old data / old callers still work, how checked): No config or data shape changes from this row. Every caller still imports the four moved names from kiro_crew.subagent; test_subagent_parts_composition_contract.py holds each as one object with its old signature.
    • Existing tests (which suites passed on this head): locally on this exact head, test_security_posture.py (57 passed) and 14 named files, among them test_subagent_standalone.py, test_subagent_parts_composition_contract.py, test_spawn_parts_contract.py and test_mcp_shared_listing.py (502 passed); mypy src/kiro_crew clean. The two functions that call a redactor were compared with main's by source text on this head: identical. CI on this exact head is running.
  • How to undo: revert this PR. The row cannot be dropped alone: test_security_posture.py fails while spawn_allowlists.py calls a redactor without a classification.

@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 11, 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.

Approve on 297b016. Since our approval on 9e455af, this head is a rebase onto main e8283ce plus one new test that compares the standalone sub-agent readers with the facade. No product code changed. I traced the early answer again. It builds the initialize result and the tool list with the same functions the dispatch loop uses. It runs only after every start-up refusal, and it reads the session's tool policy the same way the loop does. A tools/call that arrives before the handlers load is left for the loop, which answers it once and in order. The 744 tests in the 18 related files pass. Two parts of the early path have no test. If the early tools/list skipped the session's tool exclusions, no test would fail. If the loop dropped the in-flight report request from an initialize answered early, no test would fail either. Please add a test for each. The red backend shards on this head are the two tests that were red on main before #35625. The branch needs a rebase onto current main to clear them. Decisive lines: src/kiro_crew/mcp_shared_listing.py:296-305 (early tools/list uses the loop's own listable_tools and policy) ; src/kiro_crew/mcp_shared_dispatch.py:1334-1354 (carried frames answered first, in order; early initialize params carried) ; src/kiro_crew/mcp_entry.py:203 (answer runs after every start-up refusal, before the handler import) ; test/test_subagent_standalone.py (only new hunk since 9e455af)

@bolichen97 bolichen97 closed this Nov 12, 2026
auto-merge was automatically disabled November 12, 2026 05:37

Pull request was closed

@bolichen97 bolichen97 reopened this Nov 12, 2026
@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 bolichen97 closed this Nov 12, 2026
@bolichen97 bolichen97 reopened this Nov 12, 2026
@bolichen97
bolichen97 enabled auto-merge (squash) November 12, 2026 05:51
@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
@bolichen97
bolichen97 merged commit e2205ea into main Nov 12, 2026
214 of 271 checks passed
@bolichen97
bolichen97 deleted the perf/cold-session-start branch November 12, 2026 08:20
@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

Development

Successfully merging this pull request may close these issues.

Cold session start waits 1.4 s for Kiro Crew's own MCP servers to import their tool handlers before listing

4 participants