Repository navigation
perf(acp): skip the MCP no-report wait on hosts that never announce MCP servers - #37698
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS The wait-skip is aimed at the cause: only a host that names an MCP-init frame can end the wait. The new helper and cached field re-read data the runtime already reads at the same call site. Notes
What this change shipsInventory (4 items) — 3 justifiedIntent: codex, claude and goose session starts and resumes no longer stall 6 s waiting for an MCP-init frame their host never sends. This is a FIX (perf).
[FIRST-PRINCIPLES-REVIEWED] bef145a Description read[DESCRIPTION-READ] 899f00d35ec614a3785dd82cfe81aa949019a11762214dcccc014646acff930a That sha256 names the PR description this verdict read. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the drain is now gated on the harness's own [DESIGN-REVIEWED] bef145a Description read[DESCRIPTION-READ] 90f0532f9045599b0bacf085441ee2e89b658ccf6a2a655e0aac1e671811c072 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 |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
f1f0f00 to
8138992
Compare
|
Opus on f1f0f00 (acp-client.md drain paragraph still says every other agent keeps the ceiling): real, fixed in 8138992. The Coverage Gate and Detect changed surface on f1f0f00 were one infra failure: Detect changed surface died fetching the repo ( |
Code change approver recommendation: A person should decideWhy: 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 change skips the 6 s MCP-init wait only on hosts whose harness declares no 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 |
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Verified on this head: only the kiro and KAS harnesses declare the _kiro.dev/mcp/* frames that can end the no-report wait early. Codex, claude and goose declare session_update only, so on those hosts the 6 s ceiling always ran to the end, and a zero ceiling removes only dead time. The kiro and KAS paths keep the old wait, and unknown backends keep it too. The review checked the harness-parity rule (the gate reads a declared capability, not "not kiro"), found no blocking call on the event loop, and ran the 7 new tests on this head: they pass and are deterministic, with no host state. The acp-client spec is updated in the same commit.
Done well: _expect_mcp_reports is left alone, so record_switched_off(spec) still runs on every host, and a test pins that choice against the obvious refactor.
Optional:
- The tests pin the
_host_sends_mcp_initflag, not the drain call sites. Reverting only theand self._host_sends_mcp_initconjuncts leaves all 7 green. A spy ondrain_initassertingno_report_ceiling == 0.0for a codexcreate_sessionandload_session, plus a kiro case, would pin the behaviour. - The Design lane note about slow MCP servers on codex has no reply yet. A codex run with one slow
nodeserver, or a codex-acp reference showingsession/newwaits for server start, would back the "Removes nothing" claim. - A smaller shape is available: read
self._harness.notification_aliases.mcp_initat the two live sites, next to themcp_readinessread. The_wait_managed_mcpconjunct is only reached on KAS, where the flag is always True, so the spec could name two drain sites instead of three.
8138992 to
63537c3
Compare
|
Backend Tests (3.12, 1) and Coverage Gate on 63537c3: not this PR.
|
…CP servers codex-acp, claude-agent-acp and goose send no MCP-init frame, so drain_init's 6 s no-report ceiling could never end early on them and every session start and resume on AcpRuntime paid it in full. Gate the three drain sites on whether the host's harness names an MCP-init method; the spec's switched-off servers are still recorded off _expect_mcp_reports.
63537c3 to
bef145a
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved. On head bef145a the review confirmed that only the Kiro and KAS harnesses declare notification_aliases.mcp_init, and that only _kiro.dev/mcp/* frames can end the no-report wait early. On codex, claude and goose the 6 s ceiling therefore always ran to the end, and a zero ceiling removes only that wait. Kiro and KAS keep their current behaviour. A zero-ceiling drain still applies config_option_update and collects OAuth requests. An unknown backend still keeps the wait, and acp-client.md is updated in the same commit. The 7 new tests pass, and readiness is green on this head.
Done well: the gate reads the harness's own positive mcp_init declaration instead of "not kiro". A test keeps record_switched_off running on every host.
Optional:
- Add a
drain_initspy test, following the one in test/test_acp_runtime_drain_init.py, for codex create, resume and the external-only drain, so that dropping any of the threeand self._host_sends_mcp_initconjuncts makes a test fail. Today all tests stay green when those conjuncts are reverted. _host_announces_mcp_startsand itsValueErrorfallback can be dropped andself._harness.notification_aliases.mcp_initread inline.self._harnessalready raises for an unknown backend on the line before.- In the evidence sections, say that on main only codex is affected, and name the current head in the Proof line. If you have one, add a codex start timing.
Problem / Motivation
Goal: a session start or resume on
AcpRuntimestops waiting 6 s for an MCP-init frame that its host never sends.drain_initholds every session start and resume for up to_MCP_DRAIN_NO_REPORT_CEILING(6.0 s,acp/session_handle_mcp.py) until the first MCP-init frame arrives. Only the kiro family names such a frame (notification_aliases.mcp_init: kiro-cli and KAS). codex-acp, claude-agent-acp and goose send plainsession/updateonly, so on them nothing can end the wait early and every start and resume pays the full 6 s.Why it matters
This affects every codex session today, with no switch: codex is in
ACP_BACKENDS_ACP_RUNTIME, so each codex chat, cron, subagent or app session start and resume waits the full 6 s before its first turn. Shared claude and goose chats (runtime sharing preview, their switches on) pay the same. On a goose shared chat it was measured on a pod: a warm-up turn took about 7 s with the wait and about 1 s without it.Not a goal
What changed (motivation -> approach -> change)
The wait can only end on a frame the host names -> ask the host's harness whether it names one -> gate the three drain sites on that.
AcpRuntime._host_sends_mcp_init(acp/runtime_class.py), set once fromharness_for(backend).notification_aliases.mcp_init. An unknown backend keeps the wait; the spawn refuses it later with the harness's own error._expect_mcp_reports: the readiness drain inruntime_session_createandruntime_session_load, and the external-only drain inruntime_session_load. On a host that names no MCP-init frame they calldrain_init(no_report_ceiling=0.0)._expect_mcp_reportsitself is unchanged, so_guard_unresolved_mcp_refsstill callsrecord_switched_off(spec)on every host: the session's MCP status and the model's[MCP SERVERS]block still name a server the spec switched off.Backwards compatibility
Compatible: no config, data or API changes; a host that names an MCP-init frame waits as before.
Removes nothing: only the length of a wait on hosts that can never end it early changes.
Tests
test/test_acp_drain_skips_mcp_init_wait.py:_host_sends_mcp_initis False for codex, claude and goose and True for kiro-cli and KAS; on codex, claude and gooserecord_switched_off(spec)is still called; an unknown backend keeps the wait. Its module docstring names the one-line change that breaks each test._expect_mcp_reports, the shape an earlier version of this change had.test_runtime_bindings.py,test_acp_runtime_session_start.py,test_kiro_cloud_session.py,test_unattended_mcp_wait.py,test_acp_runtime.py(701 passed). flake8, black, isort and mypy are clean.Proof: PROVEN test_only_a_host_that_names_an_mcp_init_frame_waits_for_one[codex|claude|goose], test_an_unknown_backend_keeps_the_wait (head f1f0f00)
Manual verification
goose pod run (from #37567): a shared goose chat's warm-up turn took about 7 s with the wait and about 1 s without it. No separate codex run: codex-acp sends no MCP-init frame, so its saving is the same 6 s ceiling.
Screenshots / video
N/A: no user-visible UI change.
Related Issues
Split out of #37567 at its First Principles review, which asked that a change reaching every codex session not ride along under a goose switch.