Repository navigation
fix(subagent): capture each run's deadline at start and forward it to the ACP transport - #7195
Conversation
|
|
Open PR relationship auditThis is a consolidated, point-in-time code-level audit note. It compares complete merge-base diffs and current/merged code; it does not treat a shared topic as duplication or partial coverage as completion. Relationship findings
No PR, Issue, label, branch, or review state was changed by the relationship-note portion of this audit. |
|
🤖 Kiro Crew [operator: NicholasRBowers#a942f9ca]: This PR has been inactive for 7+ days with failing CI. I've assessed the blockers and they appear resolvable — I'll push fixes directly to this branch as a co-author. Assessment: The maintainer audit already mapped the rebase file-by-file (pure relocation conflict in If you'd prefer I don't touch this PR, add the |
|
Hi @rubencu, thanks for this one. Two things before it can land. Still worth doing, but the numbers need reworking. The motivation, a fixed 30-minute deadline killing healthy long runs, is already handled on main by a different mechanism: merged #8891 raised the static default in Overlap with #8003 (credit usage reporting, cc @welikoiwanenko). Shared files: Posted from the 2026-09-08 open-PR relationship audit (read-only, one auditor per PR); reply here if any of this is wrong. |
6fb9c2b to
740c27c
Compare
Design Review (Opus 5.5, fork) — ✅ PASSDesign-level review of Design-Verdict: PASS Check one thing before merge: a run that is not executing still uses its registration age against the live default. A long spawn-approval park can still be reaped before the run starts, same as on main. [DESIGN-REVIEWED] 6d633a1 Description read[DESCRIPTION-READ] 0bb20212ac9dca6d98485308f1566f7d52b0dd47e8c599ae6990d4beed059a03 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 |
First Principles Review (Opus 5.5, fork) — 🟡 CONCERNSPremise-level review of First-Principles-Verdict: CONCERNS The provider capability seam guards a "legacy duck provider" that does not exist in Not justified as shipped
What this change shipsInventory (8 items) — 5 justifiedIntent: keep a running subagent's deadline and transport budget fixed when config reloads mid-run. FIX.
[FIRST-PRINCIPLES-REVIEWED] 6d633a1 Description read[DESCRIPTION-READ] 562aaadad3f6e0e0fb01055b368ef3edb8b7d41228e6b3bdfb0bd718dc5906e6 That sha256 names the PR description this verdict read. Recompute it with |
2f15a75 to
a04b834
Compare
|
Maintainer rerun handoff for current head
Please rerun the failed GPT and Opus reviewer checks for this exact head. No code change is indicated by the available evidence. |
Open-PR triage (2026-10-05): DISTINCT, needs a rebaseWhat was checked: head Verdict: DISTINCT. There is no breaking change and I found no P0 bug. Not on main yet. None of the adaptive learner exists on main:
PR #8891 (merged) only raised the static default to 10800s. This PR already builds on that: the floor is the configured or 3h value and the default ceiling is 21600s. The 2026-09-08 audit points are addressed: config is in Other open PRs: the file overlaps are textual only. #12551, #11794, #10171 and #13320/#14861 share hunks but have different goals. No open PR implements adaptive or captured subagent deadlines. Compatibility:
Blocker: the PR is 2279 commits behind main (
Recommendation: REBASE onto current main, then KEEP. Main's |
a04b834 to
31e8ae1
Compare
|
Rebased as asked in the 2026-10-05 triage (#issuecomment-5993023490). New head The anchors from the triage, as landed
Local review before this push (CI's own review contracts, run on the exact head each round; Opus 5.5 = the CI pin; the GPT lane ran as 5.6 because the pinned 6.1 is not available locally, so CI's GPT verdict is the authoritative one):
Left as they are, deliberately
PR body: the frozen Problem / Why sections are unchanged; the template's |
|
New head What the reviews on
The learner is removed, not defended. Gone: What remains, and why each piece holds without a learner
Description: the Problem and Why sections are rewritten as well as Goal and Not a goal, because the earlier text described the learner and no longer matched the change; this comment is the record of that edit. Rebase: onto Tests: the eight changed test modules pass 435/435. Five mutations on an archive copy fail by name: a capture that re-reads the live default (2), a reaper on the manager default (1), a reaper that skips parked starts (1), a transport budget that ignores the captured deadline (5), a run that stops forwarding it (4). The owning set (214 files) passes 10,935 with 0 failed. The broad selection (1,144 files) passes 71,392 with 23 failed, and all 23 also fail without this commit: 16 on a @bolichen97: rebased onto current main as your triage asked, and the learner it described as absent from main is now absent from this PR too. |
UX Review (Opus 5.5, fork) — ⏭️ skippedRevision |
|
This PR fixes the bug where a config reload changes the deadline of a subagent run that is already executing. Each run now captures |
|
New head Hold 1, the dashboard key: removed from this PR. Hold 2, the current-head items on
Tests: the seven PR test modules pass 392/392, the 24 new or changed tests pass in 5 of 5 serial runs, and six mutations fail by name. The owning set (245 files) passes 12,432 with 0 failed. Of 13 failures in the broad selection (587 files), 11 fail identically on a |
… the ACP transport A subagent run fixes its deadline on SubagentInfo.timeout_secs when execution starts, and asyncio.wait_for, the reaper and the follow-up watcher all enforce that one value, so a config reload applies to the next run only. The reaper measures an executing run from _exec_started. A run that is not executing is measured on its registration age: against the live default while it is parked before its first start, and against its captured deadline between the two attempts of a cancel recovery. At execution start the run also resolves one ACP prompt budget at least 60s past that deadline and forwards it on every original, retry, fallback and recovery prompt through the providers that declare prompt_timeout_for_deadline. A provider that declares nothing keeps its one-argument stream(message) call.
|
Rebased onto |
iamwhatever
left a comment
There was a problem hiding this comment.
This PR stops a config reload from changing the deadline of a subagent run that is already executing. _run_impl captures agent.subagent_timeout_secs once on SubagentInfo.timeout_secs, and wait_for, the reaper, the follow-up watcher and both error messages all read that captured value. Both blockers from my last comment are resolved on 6d633a1. The _EDITABLE_CONFIG and resource-protection changes are gone from the diff, and the branch is rebased with fresh lanes on this head. I read the run, monitoring, continuation, terminal and provider hunks. The reaper now times an executing run from _exec_started_mono, matching the wait_for clock, and keeps the registration age for a parked run. The watcher's new wait for the capture is bounded, because the reaper ends a parked run. Providers that do not declare prompt_timeout_for_deadline keep the one-argument stream(message) call, and both ACP stream_events/prompt signatures already accept timeout. The tests cover a lowered config across retries and recovery, the captured deadline from execution start, and the legacy one-argument provider. First Principles' remark that the provider seam has no production legacy consumer is advisory and unanswered. It does not affect correctness. — crew-pr-reviewer (deep re-check)
Problem / Motivation
Goal: A config reload no longer changes or cuts short a subagent run that is already executing, because the run's deadline and its ACP transport budget are both fixed when it starts.
A subagent's deadline was read from the manager default at each point of use. A reload while a run executed changed the deadline the reaper compared it against, the deadline its follow-up watcher timed itself on, the deadline a cancel-recovery respawn of the same run started with, and the figure its timeout record named. The reaper also measured from registration, so time spent waiting for spawn approval counted against the run's deadline before the run started. Every prompt resolved the ACP transport wait from live config, so a reload that lowered
agent.subagent_timeout_secsfrom above the 4-hour transport floor could cut a later retry or recovery prompt below the deadline its run still enforced, and the run then ended on a raw transport timeout instead of its own deadline.Why it matters
An operator who lowers
agent.subagent_timeout_secswhile subagents run should change the next runs, not cut the work already in flight. A run that times out should name the deadline it actually enforced, and the transport layer should never be the first thing to expire.Not a goal
agent.subagent_timeout_secs.agent.subagent_timeout_secseditable from the dashboard: it is a resource-protection policy decision for a maintainer, so it stays known gap 1 indocs/architecture/resource-protection.md.stream(message)call.What changed (motivation → approach → change)
Motivation: a run's deadline and its transport wait both followed live config, so neither was fixed for the life of the run. Approach: capture both once, when execution starts, and enforce only the captured values wherever the run is timed. Change:
_run()capturesagent.subagent_timeout_secsonSubagentInfo.timeout_secswhile the record still carries the zero sentinel. Unexpected-cancel recovery respawns the same record and keeps its nonzero value.asyncio.wait_for, the reaper and the follow-up watcher all enforce that value. The reaper measures an executing run from_exec_started. A run that is not executing is measured on its registration age. Before its first start (parked at spawn approval, or approved and waiting for admission) it has captured nothing and keeps the live default as its bound. Between the two attempts of a context-overflow cancel recovery, which clears_exec_startedbefore the replacement waits for capacity, it keeps its captured deadline. The timeout and reap records name the enforced deadline.agent_sdk.capture_prompt_timeout: the larger of the live transport wait and the captured deadline plus 60 seconds. It forwards that budget on the original prompt and on every transient retry, model fallback, stop-recovery and dependency-recovery prompt.AcpProviderandAcpSessionProviderdeclareprompt_timeout_for_deadline. An undeclared provider getsNoneand keeps its one-argumentstream(message)call, with no keyword probe and noTypeErrorretry.resolve_prompt_timeout()is unchanged from main: the ordinarytimeout=Nonepath (dashboard turns, review runs) still resolves live config, bounded byagent.subagent_timeout_secswith its0sentinel.stream(message)stream(message)timeout=Nonecallers🟩 added · 🟨 changed · 🟥 removed · 🟦 unchanged
src/kiro_crew/subagent.py,src/kiro_crew/subagent_manager/run.pySubagentInfo.timeout_secsand its capture at execution start, plus the transport budget captured once per run and forwarded on every prompt.src/kiro_crew/subagent_manager/monitoring.py,continuation.py,terminal.py_exec_startedand measures a run that is not executing on its registration age, against the live default before its first start and against its captured deadline between recovery attempts. The follow-up watcher waits for the capture, and the reap record names the enforced deadline.src/kiro_crew/acp/client.py,src/kiro_crew/acp/session_provider.py,src/kiro_crew/providers/,src/kiro_crew/agent_sdk/resolve_prompt_timeout_for_deadline,prompt_timeout_for_deadlineandcapture_prompt_timeout, plus the optionaltimeoutonstream(message, timeout=None, *, allow_image=True), the shapeAcpSessionHandle.promptandAcpClient.stream_eventsalready use.docs/system-specs/modules/,src/kiro_crew/docs/subagents.md.github/black-baseline.txttest/test_prompt_timeout_follows_ceiling.pyis black-clean and leaves the baseline.test/test_acp_provider.py,test/test_acp_session_provider.py,test/test_agent_sdk_capabilities.py,test/test_prompt_timeout_follows_ceiling.py,test/test_session_sharing.py,test/test_spawn_followup.py,test/test_subagent_turn_resilience.pyRemoved from earlier revisions: the adaptive learner (
src/kiro_crew/subagent_timeout.pyandtest/test_subagent_timeout.py), theagent.subagent_timeout_autoandagent.subagent_timeout_max_secskeys with their constants,config-baseline.jsonrows, loader parsing and dashboard editors, the persistedmember-memory-bindings/subagent-timeout.jsonrecord with its write, read-back and shutdown drain, and the adaptive branch ofresolve_prompt_timeout(). Also removed: the dashboard editor foragent.subagent_timeout_secs(its_EDITABLE_CONFIGrow, the twoconfig.loaderimports and the write-gate parity row), and thedocs/architecture/resource-protection.mdedit, so that file is main's text again. The diff touches no file undersrc/kiro_crew/security/, nosrc/kiro_crew/dashboard/file and nosandbox*.py.Backwards compatibility
Compatible: every key main accepts is still accepted, and
agent.subagent_timeout_secskeeps its range, its0sentinel and its CLI andconfig.jsonediting paths. A reload now applies to the next run instead of an executing one. A run parked before its first start (at spawn approval, or approved and waiting for admission into startup) is reaped on the registration age against the live default, as before this change. A run between the two attempts of a context-overflow cancel recovery is measured on the same registration age against its captured deadline, and an executing run on its captured deadline from_exec_started. Providers that declare nothing keepstream(message), andtimeout=Nonecallers resolve live config as before.Removes nothing: the diff against main deletes no key, file, record or public function, and the learner and its keys were never on main.
Tests
0be9319eadccis one commit on maind3f462f23b4c(2026-10-10, test: use _floor_monkeypatch in poll-gate autouse fixture #18696), 24 files, +894/-34.stream(message).test_prompt_timeout_follows_ceiling.py), and a run that stops forwarding the budget fails 4.test_subagent*,test_acp*,test_config*,test_spawn_*,test_providers*,test_dashboard_config*,test_conductor_board_contract_parity, every suite that drives the reaper or reads_EDITABLE_CONFIG, and the session-health, source-pin-budget and flake-ratchet suites) passes 12,432 with 11 skipped and 0 failed. The flake ratchet, source-pin budget and config baseline also pass 117/117 serially withFLAKE_RATCHET_BASE=origin/main.git archivecopies of main and of this candidate: 10TestDoctor*intest_cli.pyand one intest_model_served_default.py. The other 2 pass on both archive copies.test_dashboard_server_composition_contract.pydepends on the built SPA this checkout links atsrc/kiro_crew/static/dist, and main's archive fails it too once that link is added. The vault-owned KAS row intest_cli_doctor.pypasses alone and as a whole file in the same checkout.git diff --checkpass.website/.Manual verification
N/A: the captured deadline, the reaper's clock, the follow-up watcher, transport forwarding on shared and dedicated providers, and legacy provider compatibility are regression-tested above, each with a mutation that fails by name.
Related Issues
N/A: this change was proposed directly in the pull request.
Pattern harvest
Not generalizable: the run's timeout was read from the manager default at each point of use instead of once per run, a lifecycle choice specific to this manager that no line pattern separates from a deliberate live read.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
N/A — placeholder wording remains pending OSPO; this PR does not invent CLA text.