Skip to content

fix(subagents): settle a dashboard tab's returned results at its turn's release - #28576

Closed
cruisercohen wants to merge 1 commit into
mainfrom
fix/23495-tab-parent-settle-at-release
Closed

cruisercohen wants to merge 1 commit into
mainfrom
fix/23495-tab-parent-settle-at-release

Conversation

@cruisercohen

@cruisercohen cruisercohen commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: a dashboard tab whose own turn called spawn_sub_agents never loses a returned child result when that turn ends without landing (the user presses Stop, the backend fails, the turn is cancelled).

On main the tab route acknowledged a dashboard-born parent's child on the mark itself (_delivered_inline), and the mark is sent once the reply frame reaches kiro-cli's pipe, which is before the turn finishes. If the turn was then stopped, the completion that would have delivered the result was already acknowledged and tombstoned. #27508 (from #17684) fixed this window for cron and channel parents with a pending mark settled at the turn's release, and listed the dashboard tab's own window as not a goal.

Why it matters

Every dashboard user who stops a turn that used spawn_sub_agents after its children returned can lose those results with no trace: no completion turn follows and the result is in no finished answer. Dashboard tabs are the most common parent.

Not a goal

  • Brokered (pooled-backend) replies (Broker<->stub delivery confirmation for brokered MCP responses #18743): they still mark nothing, so their completions are delivered as before. The draft RFC rfc-brokered-delivery-confirmation.md describes the dashboard-born exception as current behaviour; it is left for its author to update.
  • Engines other than the dashboard runner noting landing: unchanged.

What changed (motivation → approach → change)

Symptom → cause. parent_turns.settles_at_release returned False for dashboard: keys, so _flag_collected_inline flagged the child with no attempt, api_spawn_mark_collected settled queued completions on the slot at mark time, and _route_subagent_to_tab skipped on the bare mark.

Change. The dashboard-born exception is removed; every parent takes the #27508 path. That rule already runs on dashboard-runner tabs (cron and channel tabs), and the runner already notes landing on end_turn (turn_stats.py), so no runner change is needed.

  • parent_turns.py: settles_at_release removed.
  • run_control.py: _flag_collected_inline always holds the mark pending under the attempt holding the parent's permit (only when that attempt spawned and read the child); api_spawn_mark_collected no longer settles the slot at mark time. The landed release does that through _settle_inline -> _settle_collected_on_slot. Response shape (ok / no_slot) unchanged.
  • subagent_injection.py: the tab route asks _inline_verdict for every parent, so a pending mark parks the completion until the turn releases: landed confirms it (no second turn), anything else delivers it.
  • Spec docs (subagent.md, mcp.md, slack-gateway.md) updated.

Backwards compatibility

Compatible: no API or wire change; mark-collected takes and answers the same fields. On dashboard tabs a returned result whose turn did not end on end_turn now gets its completion turn (one duplicate at worst, never a loss), where before it was dropped. A landed turn still plays no duplicate.

Reader: src/kiro_crew/parent_turns.py:settles_at_release -- chat -- removed; every caller (run_control, subagent_injection, the gateway and messaging re-exports) is changed here, and git grep finds no other reader in src/ or test/
Reader: src/kiro_crew/dashboard/messaging_api/run_control.py:api_spawn_mark_collected -- chat -- a dashboard tab's queued completion is no longer settled at mark time; the landed release settles it (test_collecting_a_member_whose_announce_already_queued_settles_it)
Reader: src/kiro_crew/slack/gateway_runtime/subagent_injection.py:_route_subagent_to_tab -- chat -- skips only a confirmed mark, parks a pending one (test_a_tab_parents_landed_turn_plays_no_duplicate_and_settles_at_its_release[dashboard-tab])

Tests

Proof: PROVEN test/test_spawn_sub_agents_settle_at_release.py::test_a_dashboard_born_tab_whose_turn_is_stopped_still_gets_its_result, test/test_spawn_sub_agents_settle_at_release.py::test_a_tab_parents_landed_turn_plays_no_duplicate_and_settles_at_its_release[dashboard-tab], test/test_subagent_queued_visibility.py::test_collecting_a_member_whose_announce_already_queued_settles_it, test/test_subagent_queued_visibility.py::test_collected_ids_are_bounded_and_known (head 24eb72b)

  • test_a_dashboard_born_tab_whose_turn_is_stopped_still_gets_its_result (new) and the dashboard-tab case of test_a_tab_parents_landed_turn_plays_no_duplicate_and_settles_at_its_release: real SessionManager, real mark flagging and tab route; a stopped turn delivers the result once, a landed one plays no duplicate.
  • Tests that pinned mark-time acknowledgement are updated to the release rule: test_gateway_subagent_injection.py marks the child returned in a landed turn (_inline_state = "confirmed"); three test_subagent_queued_visibility.py tests and TestApiSpawnMarkCollected::test_records_ids_bounded_and_skips_non_strings assert the mark settles nothing and the landed-release settle does.
  • Every test file touching inline marks, parent_turns or the subagent routes, plus tests reading the spec docs: 2,150+ passed. black, isort, flake8, mypy on changed files: clean.

Manual verification

N/A — the stop-after-reply window is driven end to end through the real SessionManager, mark endpoint and tab route in the new test.

Related Issues

Fixes #23495

Sibling sweep

Swept: git grep -n "_delivered_inline(|_collected_inline" -- src/
Sibling: src/kiro_crew/slack/gateway_runtime/subagent_injection.py:102 -- not affected -- only caller left is _inline_verdict, which every route asks
Sibling: src/kiro_crew/dashboard/messaging_api/run_control.py:513 -- changed here

Pattern harvest

Not generalizable: a single predicate exempted one parent shape from the release rule; removing it closes the class.

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

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

🤖 AI-assisted PR 🤖

@cruisercohen
cruisercohen requested review from a team and KiroCrewCaptain as code owners November 2, 2026 21:49
@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Nov 2, 2026
…'s release

A dashboard tab whose turn called spawn_sub_agents acknowledged each returned
child on the mark, so a turn the user stopped before it landed lost the
result. Every parent now holds the mark pending under the spawning attempt
and settles it at that attempt's release, as cron and channel parents
already do (#17684): a landed turn confirms it, any other end delivers it.

Fixes #23495
@cruisercohen
cruisercohen force-pushed the fix/23495-tab-parent-settle-at-release branch from 3bb4601 to 24eb72b Compare November 2, 2026 21:55
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 24eb72bc80c08bf670f73ad1b6b6788ea147b36a 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 2, 2026

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 24eb72bc80c08bf670f73ad1b6b6788ea147b36a — 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. This is a net subtraction: it deletes the one exception that let a dashboard tab's returned results get acknowledged before its turn could still be stopped.

What this change ships

Inventory (5 items) — 5 justified

Intent: a dashboard user who stops a turn after its sub-agents returned still gets those results. This is a FIX (#23495).

  1. A dashboard tab's returned sub-agent result is no longer acknowledged when the reply reaches kiro-cli; it waits until that turn finishes. Removes the settles_at_release predicate — justified
  2. A stopped, failed or cancelled dashboard turn now plays the parked completion once, where before the result was lost — justified
  3. A queued completion on the tab is no longer settled when the mark arrives; only a turn that actually finished settles it, through the existing _settle_inline → _settle_collected_on_slot path — justified
  4. The tab route uses _inline_verdict for every parent, so the inline _delivered_inline branch is gone (one caller is left inside _inline_verdict) — justified
  5. Tests that pinned acknowledgement at mark time are rewritten to the rule that settles at the turn's end; the description names the decision it reverses (fix(subagent): mark returned results only after the reply is written #27508 deferred the dashboard case as not a goal) and ships a new test that fails on base — justified

[FIRST-PRINCIPLES-REVIEWED] 24eb72b

Description read

[DESCRIPTION-READ] 4d17c92dc422c586a58933152ea99b0f42575ca043fb8e0357e8b1f86b3fd7c4

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 2, 2026

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: removing the dashboard-born exception sends dashboard tabs down the existing release-settled path, and the dashboard runner already reports when a turn lands (turn_stats.py:1057).

Notes

  • If a dashboard tab's turn has no ledger token at mark time, _flag_collected_inline now flags nothing, so the completion plays as a second turn. Each such case gives a duplicate instead of a lost result. That is the intended trade-off, but any dashboard path that bypasses SessionManager claims would now show steady duplicates.

[DESIGN-REVIEWED] 24eb72b

Description read

[DESCRIPTION-READ] 25d0377a0fd91ba879b936c88da53423a0ca0d720b94ea67d89c6cfbb3dac973

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 2, 2026

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 24eb72bc80c08bf670f73ad1b6b6788ea147b36a and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 24eb72b

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

@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 24eb72b

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

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

@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 3, 2026

@iamwhatever iamwhatever 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.

REQUEST_CHANGES at 24eb72b, for one untracked follow-up only.

The fix itself looks sound. Removing settles_at_release puts dashboard tabs on the same release-settled path cron and channel tabs already use; the dashboard runner already notes landing on end_turn (turn_stats.py#L1057), and a landed release now does the slot settle that the mark used to do (subagent_injection.py#L254). No reader of the removed predicate is left in src/ or test/.

What needs to change

The Not a goal section leaves rfc-brokered-delivery-confirmation.md 'for its author to update', but nothing tracks it. That draft RFC still describes the dashboard-born exception as current behaviour (L67, L92), so whoever implements #18743 would design against a rule this PR deletes. Please either correct those two passages here, or open an issue for it and link it in the PR description.

AI findings judged non-blocking

  • Design (Opus 5.5), a dashboard turn without a ledger token at mark time now plays a duplicate completion turn: that is the stated duplicate-over-loss trade-off, and no flag is set without a token. run_control.py#L542

The red 'Publish readiness signal' job on this head failed on a GitHub API rate limit, not on code; PR Readiness was published green afterwards.

— crew-pr-reviewer (r143)

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: passed Eligible automated validation passed for the current revision labels Nov 3, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #32387; thanks for the start.

bolichen97 added a commit that referenced this pull request Nov 7, 2026
A dashboard tab whose turn called spawn_sub_agents acknowledged each
returned child on the mark, so a turn the user stopped before it landed
lost the result. Every parent now holds the mark pending under the
spawning attempt and settles it at that attempt's release, as cron and
channel parents already do (#27508): a landed turn confirms it, any
other end delivers it. The specs and the brokered-delivery RFC no
longer describe the removed dashboard-born exception.

Builds on #28576 by @cruisercohen.

Closes #23495

Co-authored-by: Matt Cohen <mattcohe@amazon.com>
iamwhatever pushed a commit that referenced this pull request Nov 7, 2026
…32387)

A dashboard tab whose turn called spawn_sub_agents acknowledged each
returned child on the mark, so a turn the user stopped before it landed
lost the result. Every parent now holds the mark pending under the
spawning attempt and settles it at that attempt's release, as cron and
channel parents already do (#27508): a landed turn confirms it, any
other end delivers it. The specs and the brokered-delivery RFC no
longer describe the removed dashboard-born exception.

Builds on #28576 by @cruisercohen.

Closes #23495

Co-authored-by: Matt Cohen <mattcohe@amazon.com>
buluoray added a commit that referenced this pull request Nov 8, 2026
…32387)

A dashboard tab whose turn called spawn_sub_agents acknowledged each
returned child on the mark, so a turn the user stopped before it landed
lost the result. Every parent now holds the mark pending under the
spawning attempt and settles it at that attempt's release, as cron and
channel parents already do (#27508): a landed turn confirms it, any
other end delivers it. The specs and the brokered-delivery RFC no
longer describe the removed dashboard-born exception.

Builds on #28576 by @cruisercohen.

Closes #23495

(cherry picked from commit 2a4fb38)

Original author: Bolin Chen (#32387). docs/system-specs/modules/subagent.md hand-resolved: removed the dashboard-born-tab sentence this PR makes untrue and kept the rest of release's paragraph; main's #25261 sentence belongs to a main change not on release.
@iamwhatever

Copy link
Copy Markdown
Contributor

Thanks for this work! The same change has since landed on main in #32387 ("fix: settle a dashboard tab's returned results at its turn's release"), which closed the linked issue #23495. Closing this one as superseded. Please reopen if something here is still missing from main.

@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A tab parent acknowledges a returned spawn_sub_agents result while its own turn can still be stopped

3 participants