Skip to content

fix: show a nested sub-agent's approval prompts in its root chat - #36660

Open
bolichen97 wants to merge 1 commit into
mainfrom
fix/28364-nested-prompts-root-chat
Open

bolichen97 wants to merge 1 commit into
mainfrom
fix/28364-nested-prompts-root-chat

Conversation

@bolichen97

@bolichen97 bolichen97 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: A sub-agent spawned by another sub-agent asks for approval in the chat its spawn tree started from, so the person can see and answer it; whether a call is asked at all does not change.

A run two or more levels deep asks under its parent's subagent:<id> key, which no chat tab shows. Its spawn prompt is raised on that key and its tool prompts on no tab at all, so the run waits on a prompt the person never sees in the chat they are working in.

Why it matters

Anyone whose sub-agents delegate further (a planner that spawns workers, a worker that spawns a helper) hits it: the nested run stalls on an approval that is invisible in the chat, until the wait expires and the call is denied. The work the person asked for silently does not happen.

Not a goal

  • Changing which calls are approved without asking. A nested run still gets its chat's Trust only through its live parent runs, as decided on the issue; the root chat's Trust does not answer a nested run's prompt.
  • Routing for sub-agents whose tree starts at a workflow step (wf: keys), and where a nested prompt is posted outside the dashboard (a messaging integration's thread); both are unchanged.
  • Any frontend change: the dashboard already shows a spawn prompt in the same tab as the run's own card, as it does for a direct sub-agent.

What changed (motivation → approach → change)

A nested run's approval prompt now opens in the chat its spawn tree started from, the same tab where its card already draws, so the person can answer it there. The root chat's Trust still does not answer it.

The cause was one value doing two jobs. _approve in slack/gateway_runtime/turn_approvals.py used approval_slot both as the slot whose Trust may approve a call and as the tab the prompt is raised in. A nested run asks under its parent's subagent:<id> key, which no tab shows, so a tool prompt got no tab at all (the global approvals feed only) and a spawn prompt got the raw subagent:<id> slot, which no tab reads.

Before After
Tab a nested run's spawn or tool prompt is raised in none ("" or subagent:<id>) the root chat's tab
Slot whose Trust may approve that call the run's own parent key unchanged
A direct sub-agent's prompt its parent's tab, its Trust unchanged

approval_slot is computed as before and stays the Trust slot. A separate prompt_slot feeds only the two request_approval(..., slot=...) calls: for a subagent: parent key it is the tab of the run's root chat, found with the lookup the nested file card already uses (_subagent_parent_session_key in dashboard/handlers/files.py), and it falls back to today's slot when the root has no open tab. docs/system-specs/modules/subagent.md says where nested prompts are raised, and that only on that fallback does a spawn prompt keep the subagent: slot where the client holds a second card copy. The touched test file is black-clean, so its .github/black-baseline.txt row is pruned.

Backwards compatibility

Compatible: only the tab a nested run's dashboard prompt is raised in changes; every call that was asked is still asked, and every automatic approval decision is unchanged.

Removes nothing: no key, field, function or record is removed or tightened, and a prompt whose root has no open tab keeps its old slot.

Tests

  • test/test_background_approval_routing.py::TestNestedSubagentPromptShowsInRootChat::test_nested_prompt_is_raised_in_root_tab_and_not_auto_approved: a prompt asked under subagent:p1, whose run names dashboard:main as its root, is raised in tab main, and a trusted main does not approve it. Red before the fix (AssertionError: assert '' == 'main'), green after.

Proof: PROVEN test/test_background_approval_routing.py::TestNestedSubagentPromptShowsInRootChat::test_nested_prompt_is_raised_in_root_tab_and_not_auto_approved (head 1d1d8cbb5ab8)

Determinism, on Linux with pytest-randomly and pytest-repeat:

$ python -m pytest -n0 -q test/test_background_approval_routing.py::TestNestedSubagentPromptShowsInRootChat --count=200 -p randomly -p repeat
200 passed
$ python -m pytest -n0 -q test/test_background_approval_routing.py --count=5 -p randomly -p repeat --randomly-seed=<1, 2, 3, 12345>
120 passed for each seed
$ python -m pytest -n auto --dist loadgroup -q test/test_background_approval_routing.py --count=10 -p randomly -p repeat
240 passed

python -m pytest -n0 test/test_flake_pattern_ratchet.py: 68 passed. Semgrep 1.78.0 on the diff (--baseline-commit merge-base, --error): exit 0.

Manual verification

Reproduced and smoke-tested on Linux (Ubuntu, Python 3.12). A real nested orchestration needs a signed-in model, and the packaged fake ACP backend does not orchestrate sub-agents, so the exact product path was driven in-process: the real GatewayOrchestrator._interactive_approval callback, a real DashboardState with tab main, a real SubagentManager holding SubagentInfo records whose root_session_key follows admission's stamping rule, and the spawn slot resolver's body over the real _spawn_parent_slot. The pending record's slot was read from _pending_approvals; a rejecting stand-in plays the person.

Before the fix:

--- tab 'main' trust=False
(a) nested tool prompt under subagent:p0 -> pending slot='' result=False
(b) nested spawn prompt spawn:x under subagent:p1 -> pending slot='subagent:p1' result=False
(c) direct sub-agent prompt under dashboard:main -> pending slot='main' result=False (prompted)
--- tab 'main' trust=True
(a) nested tool prompt under subagent:p0 -> pending slot='' result=False
(b) nested spawn prompt spawn:x under subagent:p1 -> pending slot='subagent:p1' result=False
(c) direct sub-agent prompt under dashboard:main -> pending slot=None result=True (auto-approved, no prompt)

After the fix:

--- tab 'main' trust=False
(a) nested tool prompt under subagent:p0 -> pending slot='main' result=False
(b) nested spawn prompt spawn:x under subagent:p1 -> pending slot='main' result=False
(c) direct sub-agent prompt under dashboard:main -> pending slot='main' result=False (prompted)
--- tab 'main' trust=True
(a) nested tool prompt under subagent:p0 -> pending slot='main' result=False
(b) nested spawn prompt spawn:x under subagent:p1 -> pending slot='main' result=False
(c) direct sub-agent prompt under dashboard:main -> pending slot=None result=True (auto-approved, no prompt)

Both nested prompts land in the root chat's tab and, with that tab trusted, are still asked. A direct sub-agent's prompt still lands in main and is still approved by main's Trust with no prompt.

Related Issues

Closes #28364

The nested Trust rule and the nested file card (#35749) are already on main; this is the last part the issue's decision named.

Sibling sweep

Swept: git grep -n "request_approval(" -- src/kiro_crew
Sibling: src/kiro_crew/slack/gateway_runtime/turn_approvals.py -- changed here
Sibling: src/kiro_crew/slack/gateway_runtime/service_boot.py -- not affected -- the task runner's gate names a run and a task, never a sub-agent parent key
Sibling: src/kiro_crew/slack/handler_runtime/permission_ladder.py -- not affected -- a chat's own approvals are raised in the slot that runs the turn

Pattern harvest

Not generalizable: the defect was one value doing two jobs (the Trust slot and the prompt's tab) in one callback; the fix separates them at the only place both are read.

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 sub-agent spawned by another sub-agent asks for approval under its
parent's subagent:<id> key, which no dashboard tab is named. Its tool
prompts were raised with no slot (global feed only) and its spawn
prompts in the raw subagent:<id> slot, so neither appeared in the
chat its spawn tree started from, where they could be answered.

_approve now raises the dashboard prompt in the tab of the run's root
chat (the same lookup the file card uses), falling back to today's
slot when the root has no open tab. Trust is still read from the
run's own parent key, so the root chat's Trust does not auto-approve
a nested run's call: moving the prompt changes where it is answered,
never whether it is asked.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5) — ⏭️ skipped

Revision 47529e4ef01825eec4f08550d66aafbd6805e24b 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

Design Review (Opus 5.5) — ✅ PASS

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

Design-Verdict: PASS

Nothing blocks: the fix splits the tab a prompt is shown in from the slot whose Trust approves it, at the one place both were read, and Trust behaviour is unchanged.

Notes

  • turn_approvals.py now imports _subagent_parent_session_key, a private helper in dashboard/handlers/files.py, and it already has a second caller in file_api/outbox.py. A gateway-runtime callback depending on a private handler function couples the two layers. Moving the lookup somewhere neutral, such as next to dashboard_slot_key or onto the sub-agent manager, would give it a clear owner.

[DESIGN-REVIEWED] 47529e4

Description read

[DESCRIPTION-READ] 49d4f2d06240b437ae305dd48676b43ed0910c27a794cb883093015504fa958d

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

First Principles Review (Opus 5.5) — ✅ PASS

Premise-level review of 47529e4ef01825eec4f08550d66aafbd6805e24b — 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 single mechanism-level fix with a linked issue (#28364) and a test that fails on base, and it reuses the existing root-chat lookup.

What this change ships

Inventory (4 items) — 4 justified

Intent: let a person see and answer a nested sub-agent's approval prompt in the chat its spawn tree started from. FIX.

  1. A nested run's tool prompt now opens in the root chat's tab instead of on no tab. — justified
  2. A nested run's spawn prompt now opens in the root chat's tab instead of the unshown subagent:<id> slot. — justified
  3. When the root has no open tab, a prompt falls back to the slot it used before. — justified
  4. The test file is black-reformatted and its baseline row is removed. — justified

[FIRST-PRINCIPLES-REVIEWED] 47529e4

Description read

[DESCRIPTION-READ] 9081807094685e2ca73defe7b7c467174c3ea6336a424c82df3f44134ce3f7c9

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

Opus 5.5 Review — ✅ no blocking findings

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

Review details

No findings.

[OPUS-REVIEWED] 47529e4

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

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

@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review — ✅ no blocking findings

GPT 6.1 completed its review of 47529e4ef01825eec4f08550d66aafbd6805e24b and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 47529e4

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

@KiroCrewCaptain

Copy link
Copy Markdown
Collaborator

Code change approver recommendation: Approve

Why: the decider estimates a 10% chance that this change introduces a defect, within the 12% limit for approving on its own, and every check passes.

The PR keeps the Trust slot (approval_slot, unchanged and still the only input to the trust check, the Crew Mode check and the Slack routing) separate from the tab a prompt is shown in (prompt_slot, used only by the two request_approval calls). For a subagent: parent key, prompt_slot is the root chat's tab, looked up with the existing _subagent_parent_session_key helper (root first, then parent), and it falls back to the old slot when no tab is open. Spawn approvals pass the real subagent:<id> parent key, so both spawn and tool prompts are rerouted. When the root's tab is open, the prompt's slot matches the slot the run's cards are drawn in. The approval record's slot drives expiry and resolution broadcasts, late-click targets and the Needs Approval lane, and all of these follow the prompt consistently. Workflow-step (wf:) roots fall back unchanged. The new test would fail without the change and asserts both the tab and that Trust doesn't auto-approve. The doc update is accurate. No regression or trust-boundary weakening found.

An automated recommendation, not a review: a maintainer still decides. It approves on its own only when the estimated chance of a defect is at most 12% and the change has at most 400 changed lines. Decider v3c (217fe607) · commit 47529e4ef0 · 74 changed lines. If this recommendation is wrong, reply here: replies are how the approver is evaluated.

@bolichen97
bolichen97 enabled auto-merge (squash) November 13, 2026 14:51
@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Nov 13, 2026
@bolichen97

Copy link
Copy Markdown
Contributor Author

[operator: bolichen97] The only red on this head is main's, not this change's: test/test_mate_conductor_parity.py::test_every_shared_rule_has_an_ultra_counterpart_or_a_named_gap (Backend Tests shard 3 on Linux and Windows, with Coverage Gate failing closed behind it). #36652 fixed it on main after this head's base. A re-sync onto a main that carries that fix is reviewed and ready, and goes out when CI has room; the change itself is the same.

@github-actions github-actions Bot added the merge conflict Branch has merge conflicts with its base — author must resolve before merge label Nov 15, 2026

This branch has not been deployed

No deployments
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 readiness: action required A blocking check or review needs attention

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sub-agents spawned by a sub-agent don't inherit the chat's Trust

2 participants