Skip to content

fix: record an unanswered spawn prompt as the host's decline - #35157

Merged
bolichen97 merged 1 commit into
mainfrom
fix/31930-host-attributed-spawn-expiry
Nov 11, 2026
Merged

bolichen97 merged 1 commit into
mainfrom
fix/31930-host-attributed-spawn-expiry

Conversation

@bolichen97

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A spawn prompt that ends with nobody answering it (its window closes on the dashboard or on a chat channel, or a Stop or reap cancels it while it is open on the dashboard) is recorded in the crew log as the host's decision, not as a person declining.

When a sub-agent spawn needs approval and nobody answers, the parent's crew log writes approval/decided as rejected with no by, which reads as "a person said no". It happens when the dashboard is the only surface and its wait expires, when a Telegram or Discord prompt's wait elapses with no press, and when the run is stopped or reaped while a dashboard-only prompt is open.

Why it matters

The crew log is the record an operator reads to learn who decided what. An expired or stopped prompt shown as a person's decline blames a person for a refusal nobody made, on the most common install shape: the dashboard alone, where an attended prompt waits two hours.

Not a goal

What changed (motivation → approach → change)

The spawn gate already writes by: host when its approval callback returns a HostSpawnDecision, and writes its own host-attributed cancel when its wait is cancelled (#31954). Three waits handed it a plain False instead, the same value as a person's Deny:

Path Before After
A dashboard-only prompt expires False: a person's rejected the host's decline, cause: approval_timeout
A Stop or reap while a dashboard-only prompt is open the cancel was swallowed into False: a person's rejected the cancel reaches the gate, which writes its host-attributed cancel
A Telegram or Discord prompt elapses with no press False: a person's rejected the host's decline, cause: approval_timeout

ApprovalCoordinator.request (dashboard/interaction_coordinator.py) and DashboardState.request_approval (state_parts/dashboard_services.py) take an optional on_host_decision. Only the spawn gate's dashboard-only fallback in turn_approvals.py passes it, so every other caller (tool prompts, task runner gates, cron, the dashboard half of the owner-DM race) still reads an expiry and a cancel as False. The channel seam's unpressed_wait_answer (messaging/spawn_approval_delivery.py) returns HostSpawnDecision(False, "approval_timeout") for an unpressed wait on a still-permitted channel, which covers both channel hooks at once; their return types name it. messaging may not import the subagent facade, so HostSpawnDecision moves unchanged from subagent_parts/delivery.py into the leaf module subagent_host_decision.py, and subagent.py re-exports it. The subagent, messaging, gateway and dashboard specs say the same.

Backwards compatibility

Compatible: the new keyword is optional and only the spawn gate passes it, and a HostSpawnDecision decline is falsy, so every spawn that was refused is still refused and every other caller's answer is unchanged.

A Stop or reap while a dashboard-only prompt is open now ends the way the same cancel already ends on Slack, Telegram and Discord: the reaper's own teardown stops and reports the run, and the gate no longer writes a spawn rejected error or a spawn_run rejected audit row for a refusal nobody made.

Reader: src/kiro_crew/sel_reader.py:recent -- subagent -- the audit log loses only the rejected row a cancelled dashboard-only prompt wrote; the crew log records the gate's host-attributed cancel, as on the other surfaces (test_spawn_approval_no_surface.py::TestADashboardOnlyPromptEndsAsTheHosts)

Tests

  • test_spawn_approval_no_surface.py::TestADashboardOnlyPromptEndsAsTheHosts drives the real gateway callback over a real dashboard wait: an expired prompt is reported as the host's with approval_timeout, and a cancel while it is open is raised to the gate instead of answering False.
  • The Telegram and Discord tests for an unpressed wait on a still-permitted channel assert HostSpawnDecision(False, "approval_timeout") instead of False (test_spawn_approval_delivery_governance.py, test_discord_spawn_approval_delivery.py, test_spawn_approval_delivery.py).
  • The gateway's own test pins that a tool prompt's dashboard wait passes no hook. The Telegram and Discord composition contracts pin the hooks' widened return type, and the dashboard state's contract pins the new on_host_decision keyword.
  • test_messaging_commands.py::TestLayering::test_the_host_spawn_decision_comes_from_a_leaf_module pins that subagent_host_decision.py imports nothing from kiro_crew and holds the class kiro_crew.subagent re-exports.

Proof: PROVEN test/test_discord_spawn_approval_delivery.py::test_an_unpressed_wait_on_a_still_authorized_channel_still_denies, test/test_slack_gateway.py::TestInteractiveApproval::test_parent_session_routes_tool_approval_when_spawn_resolver_misses, test/test_spawn_approval_delivery.py::TestTelegramDeliveryHook::test_a_generation_rotation_between_spawn_and_press_expires_the_prompt, test/test_spawn_approval_delivery_governance.py::TestAMidWaitDenyFallsThrough::test_a_timeout_on_a_still_permitted_channel_is_a_host_decline, test/test_spawn_approval_delivery_governance.py::TestTheSeamOwnsTheReading::test_the_helper_declines_while_permitted_and_answers_none_once_denied (head 1c318ce)

Determinism: the 15 changed tests passed 20/20 at -n0, 10/10 at -n 4 --dist loadgroup --max-worker-restart=2 beside test_spawn_approval_delivery.py and test_discord_spawn_approval_delivery.py, and in a shuffled order (seed 27788).

Manual verification

N/A — unit coverage runs the real gateway callback over a real dashboard wait and both real channel hooks; no surface renders anything new.

Related Issues

Part of #31930

Sibling sweep

Swept: git grep -n "register_channel_delivery(" -- src; git grep -n "request_approval(" -- src; git grep -n "unpressed_wait_answer" -- src
Sibling: src/kiro_crew/telegram/dispatch/spawn_approval.py -- changed here
Sibling: src/kiro_crew/discord/transport_dispatch_spawn_approval.py -- changed here
Sibling: src/kiro_crew/subagent_manager/run.py -- tracked in #31930
Sibling: src/kiro_crew/telegram/renderer_approval.py -- not affected -- only a tool prompt's failed post marks a key undelivered; a spawn prompt posts its own card and falls through when that post fails

Pattern harvest

Rule candidate: review-prompt
Pattern: an approval wait that maps an expiry or a cancel to the same False a person's Deny returns, for a caller that records who decided

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

A spawn prompt that nobody answered was written to the parent's crew
log as a person's decline. With the dashboard as the only surface, the
coordinator's wait returned False both when it expired and when a Stop
or reap cancelled it, the same value as a Deny. On Telegram and Discord
an unpressed wait came back from the delivery seam as a bare False too.

ApprovalCoordinator.request and DashboardState.request_approval take an
optional on_host_decision. The gateway's spawn gate passes it in its
dashboard-only fallback, so an expiry is reported as the host's with
cause approval_timeout and a cancel reaches the gate, which records its
own host-attributed cancel. Every other caller still reads both as
False. The seam's unpressed_wait_answer returns
HostSpawnDecision(False, approval_timeout), which covers both channel
hooks. No approve or reject outcome changes.

A running child's tool prompt answered by a gateway shortcut is the
fourth path in the issue and lands separately.

Part of #31930
@bolichen97
bolichen97 requested review from a team and KiroCrewCaptain as code owners November 11, 2026 07:12
@bolichen97
bolichen97 enabled auto-merge (squash) November 11, 2026 07:18
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running and removed readiness: action required A blocking check or review needs attention labels Nov 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 1c318ce5bd5db2da4a4b74d13f9b3a954f73cbcd touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 1c318ce5bd5db2da4a4b74d13f9b3a954f73cbcd — 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. Each item fixes the mechanism that turned an unanswered spawn prompt into a plain False. The one sibling left (run.py tool prompts) is excluded under ## Not a goal and tracked in #31930.

Inventory (5 items) — 5 justified

Intent: let an operator reading the crew log tell a spawn refusal nobody made (expired, stopped or reaped prompt) apart from a person's Deny. FIX.

  1. A dashboard-only spawn prompt that expires is now logged as the host's decline with cause: approval_timeout, not a person's rejected — justified
  2. A Stop or reap while a dashboard-only prompt is open now reaches the gate's existing host-attributed cancel (admission/pump.py:1307-1310); the spawn rejected error and audit row are gone — justified
  3. A Telegram or Discord prompt whose wait elapses with no press is logged as the host's decline (unpressed_wait_answer) — justified
  4. New optional on_host_decision keyword on ApprovalCoordinator.request / DashboardState.request_approval. It has 1 consumer, the spawn gate's dashboard fallback, and passes on the gateway's existing on_host_decision — justified
  5. HostSpawnDecision moves unchanged into the leaf module subagent_host_decision.py, so messaging can return it without importing subagent; subagent re-exports it — justified

[FIRST-PRINCIPLES-REVIEWED] 1c318ce

Description read

[DESCRIPTION-READ] 674f82e9df56627f4405b328ffe0c7a218d5a494fc94c2c9f5c2455e0060e833

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

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the expiry hook is opt-in and only the spawn gate passes it, and the gate already records a cancel as the host's.

Notes

  • HostSpawnDecision moves into its own module but stays the same class object, and kiro_crew.subagent still re-exports it. So the gate's isinstance(answer, HostSpawnDecision) check in admission/pump.py, which gets the class through subagent, keeps matching.
  • On the dashboard path, a cancel now reaches the gate as an exception instead of returning False. That relies on the coordinator's finally block still clearing the pending approval record when the wait is cancelled. It does today; keep that cleanup in the finally if the code there is reworked.

[DESIGN-REVIEWED] 1c318ce

Description read

[DESCRIPTION-READ] c8ecfab007e22dc05b7df4366d15102208e309ff3e8ea4980470c9909e734fff

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

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 1c318ce5bd5db2da4a4b74d13f9b3a954f73cbcd and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 1c318ce

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

@github-actions

Copy link
Copy Markdown
Contributor

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 1c318ce

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

False positive or not applicable? A repository writer can comment:
/ai-review override fable 1c318ce5bd5db2da4a4b74d13f9b3a954f73cbcd 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 11, 2026

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

Approve on 1c318ce. When nobody answers a spawn prompt (it expires on the dashboard alone, it is cancelled while open there, or a Telegram/Discord wait elapses unpressed), the crew log now records the host as the decider instead of a person; every refusal stays a refusal and every other caller's answer is unchanged. Decisive lines: src/kiro_crew/dashboard/interaction_coordinator.py:195-203, src/kiro_crew/slack/gateway_runtime/turn_approvals.py:599-612, src/kiro_crew/messaging/spawn_approval_delivery.py:228-229, src/kiro_crew/slack/gateway_runtime/subagent_wiring.py:363-388, src/kiro_crew/subagent_manager/admission/pump.py:1307-1310,1350-1361,1420-1426

@bolichen97
bolichen97 merged commit 7142718 into main Nov 11, 2026
97 of 103 checks passed
@bolichen97
bolichen97 deleted the fix/31930-host-attributed-spawn-expiry branch November 11, 2026 08:54
@github-actions github-actions Bot removed the readiness: passed Eligible automated validation passed for the current revision label Nov 11, 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