Repository navigation
fix(acp): give initialize a cold-start budget on every host (release/0.8.0) - #16402
Conversation
The ACP runtime gave `initialize` the plain 30s request budget unless the agents slice was throttling at spawn. kiro-cli answers `initialize` only once it has started, so an unthrottled host with a slow cold start failed every turn with `Request initialize timed out after 30s` and the spawn guard then killed a process that was still making progress. `initialize` now always gets `_INITIALIZE_TIMEOUT` (90s, the value the throttled path already used, still below the subagent startup watchdog). Other control-plane requests keep 30s. A timeout that lands while the process is alive and the slice is throttling is still reported as `AcpRuntimeOverloaded`. The late-throttle extension is removed, since the full budget now applies from the start. A timed-out `initialize` is no longer kept registered in `_pending_requests`. Nothing read that future once the handshake gave up, so the cleanup kill's `_mark_dead` failed it unread and asyncio logged `Future exception was never retrieved`. Only `session/new` keeps its timed-out request, for the StartCollector that adopts it. Backport adaptation: hand-ported to release/0.8.0's runtime.py, whose surrounding code differs; the same edits as the source were made to _INITIALIZE_TIMEOUT, its comment, _initialize_handshake and _send_and_await's timeout branch. The test_agents_slice_admission.py hunks applied as-is, and the resource-protection.md row got the same sentence change by hand; test_acp_refactor_create_guard.py and test_pid_reader_ratchet.py do not exist on release/0.8.0, so their one-line edits are dropped. (cherry picked from commit 7a047fd) Co-authored-by: Joe Guo <zejiangg@amazon.com>
Design Review (Fable 5) — ✅ PASSDesign-level review of Design-Verdict: PASS Verify the hand-ported hunks match merged #15658 line-for-line (the stated one-comment exception aside) before merging to the release branch. [DESIGN-REVIEWED] e4174cc |
First Principles Review (Fable 5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Hand-ported backport: verify What this change shipsInventory (7 items) — 7 justifiedIntent: FIX — on release/0.8.0, a slow unthrottled cold start no longer fails every turn at the 30s
[FIRST-PRINCIPLES-REVIEWED] e4174cc |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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 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: |
Problem / Motivation
Goal: on release/0.8.0, a slow cold start no longer fails every turn with
Request initialize timed out after 30s.At the release/0.8.0 tip,
_initialize_handshakegivesinitializethe plain 30 s request budget unless the agents slice is throttling at spawn (runtime.py:_INIT_TIMEOUT_UNDER_THROTTLE if throttled_at_spawn else _REQUEST_TIMEOUT). kiro-cli answersinitializeonly after it has started. On an unthrottled host with a slow cold start (a large skill tree, a slow disk), every turn fails at 30 s, and the spawn guard then kills a process that was still making progress.Why it matters
The failure repeats on every turn for an affected host, and every retry pays the same cold start again, so there is no recovery.
Not a goal
What changed (motivation → approach → change)
Backport of #15658 to release/0.8.0, hand-ported.
initializenow always gets_INITIALIZE_TIMEOUT(90 s). That is the value the throttled path already used, and it is still below the subagent startup watchdog.AcpRuntimeOverloaded.initializeis no longer left registered in_pending_requests. Onlysession/newkeeps its timed-out request, for the StartCollector that adopts it.Why by hand: release/0.8.0's
runtime.pyhas different surrounding code (the cold-start admission sits beside the constant), socherry-pickconflicted on context only. The same edits were made by hand:_initialize_handshake's budget, log line and docstring;_send_and_await's timeout branch;Every
+/-line inruntime.pymatches the source except one comment, which keeps release's "the cold-start semaphore below" wording, since on release the semaphore is defined just below it.The other files:
test_agents_slice_admission.pyapplied as-is.resource-protection.mdrow got the same sentence change by hand.test_acp_refactor_create_guard.pyandtest_pid_reader_ratchet.pydo not exist on release/0.8.0, so their one-line edits are dropped.This is the same commit, split out of #16385.
Backwards compatibility
Compatible. A start that answers within 30 s behaves as before, and a slower live one now succeeds instead of being killed.
Tests
Regression proof: with
runtime.pyreverted to release/0.8.0 (and_INITIALIZE_TIMEOUTaliased so the test module imports), 4 of 35test_agents_slice_admission.pytests fail:test_initialize_gets_the_cold_start_budget[unthrottled]test_unthrottled_slow_cold_start_succeeds_within_the_budgettest_failed_handshake_cleanup_leaves_no_unretrieved_futuretest_initialize_past_the_budget_still_times_outGates:
src/kiro_crewreports no issues.session_agent_selection.pyoffender, which is already present at the release/0.8.0 tip.Manual verification
N/A. The tests drive the real handshake against a fake slow process.
Related Issues
Backport of #15658 (refs #11807, #11482).
Pattern harvest
Not generalizable: a backport; the source PR carries its own harvest.
Checklist