Skip to content

fix(acp): give initialize a cold-start budget on every host (release/0.8.0) - #16402

Merged
bolichen97 merged 1 commit into
release/0.8.0from
backport/0.8.0-p0-initialize-cold-start
Oct 3, 2026
Merged

bolichen97 merged 1 commit into
release/0.8.0from
backport/0.8.0-p0-initialize-cold-start

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

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_handshake gives initialize the 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 answers initialize only 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

  • No change to the budget of any other control-plane request (they keep 30 s).
  • No change to the overload verdict or to the subagent startup watchdog.

What changed (motivation → approach → change)

Backport of #15658 to release/0.8.0, hand-ported.

  • initialize now always gets _INITIALIZE_TIMEOUT (90 s). That is the value the throttled path already used, and it is still below the subagent startup watchdog.
  • A timeout that lands while the process is alive and the slice is throttling is still AcpRuntimeOverloaded.
  • The late-throttle extension is removed, because the full budget now applies from the start.
  • A timed-out initialize is no longer left registered in _pending_requests. Only session/new keeps its timed-out request, for the StartCollector that adopts it.

Why by hand: release/0.8.0's runtime.py has different surrounding code (the cold-start admission sits beside the constant), so cherry-pick conflicted on context only. The same edits were made by hand:

  • the constant and its comment;
  • _initialize_handshake's budget, log line and docstring;
  • the removed extension block;
  • _send_and_await's timeout branch;
  • two comments.

Every +/- line in runtime.py matches 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.py applied as-is.
  • 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.

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.py reverted to release/0.8.0 (and _INITIALIZE_TIMEOUT aliased so the test module imports), 4 of 35 test_agents_slice_admission.py tests fail:

  • test_initialize_gets_the_cold_start_budget[unthrottled]
  • test_unthrottled_slow_cold_start_succeeds_within_the_budget
  • test_failed_handshake_cleanup_leaves_no_unretrieved_future
  • test_initialize_past_the_budget_still_times_out

Gates:

  • Every test file referencing the ACP runtime or the slice throttle (110 files): 7545 passed, 32 skipped.
  • The baselined black and subprocess-encoding gates, isort and flake8 pass. mypy on src/kiro_crew reports no issues.
  • The comment-history gate (base origin/release/0.8.0) and docs-lint pass.
  • The agent-SDK boundary gate reports only the session_agent_selection.py offender, 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

  • At most two commits (one is the norm), with a Conventional Commits title
  • 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

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>
@bolichen97
bolichen97 requested a review from a team as a code owner October 3, 2026 06:55
@bolichen97
bolichen97 requested review from dodgeblaster and removed request for a team October 3, 2026 06:55
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Oct 3, 2026
@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of e4174cc0763098351fb18ed6160ab80e88d713d2 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

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

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Fable 5) — ✅ PASS

Premise-level review of e4174cc0763098351fb18ed6160ab80e88d713d2 — 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/CONCERNS are advisory.

First-Principles-Verdict: PASS

Hand-ported backport: verify runtime.py's edits byte-match merged #15658 (the description claims all but one comment do), since no automated cherry-pick checked it.

What this change ships

Inventory (7 items) — 7 justified

Intent: FIX — on release/0.8.0, a slow unthrottled cold start no longer fails every turn at the 30s initialize timeout (backport of #15658).

  1. initialize now always gets the 90s cold-start budget, throttled or not — justified
  2. The late-throttle mid-handshake extension mechanism is deleted (full budget applies from the start) — justified
  3. A timed-out initialize is no longer left registered, removing the unretrieved-future warning — justified
  4. Constant renamed _INIT_TIMEOUT_UNDER_THROTTLE → _INITIALIZE_TIMEOUT; zero stale references remain — justified
  5. Throttle warning log outcome retagged throttled_budget → throttled_at_spawn (old tag named removed behavior) — justified
  6. resource-protection.md throttle row updated in the same commit — justified
  7. Tests rewritten to pin the new budget, including a regression test failing on base — justified

[FIRST-PRINCIPLES-REVIEWED] e4174cc

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of e4174cc0763098351fb18ed6160ab80e88d713d2 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] e4174cc

False positive or not applicable? A repository writer can comment:
/ai-review override gpt e4174cc0763098351fb18ed6160ab80e88d713d2: <one-sentence reason>

@github-actions

github-actions Bot commented Oct 3, 2026

Copy link
Copy Markdown
Contributor

Opus 5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] e4174cc

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable e4174cc0763098351fb18ed6160ab80e88d713d2: <one-sentence reason>

@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 Oct 3, 2026
@bolichen97
bolichen97 merged commit b3253ef into release/0.8.0 Oct 3, 2026
22 checks passed
@bolichen97
bolichen97 deleted the backport/0.8.0-p0-initialize-cold-start branch October 3, 2026 07:16
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Oct 3, 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.

2 participants