Repository navigation
fix: show a nested sub-agent's approval prompts in its root chat - #36660
bolichen97 wants to merge 1 commit into
Conversation
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>
UX Review (Opus 5.5) — ⏭️ skippedRevision |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of 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
[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 |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of 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 shipsInventory (4 items) — 4 justifiedIntent: let a person see and answer a nested sub-agent's approval prompt in the chat its spawn tree started from. FIX.
[FIRST-PRINCIPLES-REVIEWED] 47529e4 Description read[DESCRIPTION-READ] 9081807094685e2ca73defe7b7c467174c3ea6336a424c82df3f44134ce3f7c9 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Code change approver recommendation: ApproveWhy: 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 ( 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 |
|
[operator: bolichen97] The only red on this head is main's, not this change's: |
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
wf:keys), and where a nested prompt is posted outside the dashboard (a messaging integration's thread); both are unchanged.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.
_approveinslack/gateway_runtime/turn_approvals.pyusedapproval_slotboth 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'ssubagent:<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 rawsubagent:<id>slot, which no tab reads.""orsubagent:<id>)approval_slotis computed as before and stays the Trust slot. A separateprompt_slotfeeds only the tworequest_approval(..., slot=...)calls: for asubagent: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_keyindashboard/handlers/files.py), and it falls back to today's slot when the root has no open tab.docs/system-specs/modules/subagent.mdsays where nested prompts are raised, and that only on that fallback does a spawn prompt keep thesubagent:slot where the client holds a second card copy. The touched test file is black-clean, so its.github/black-baseline.txtrow 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 undersubagent:p1, whose run namesdashboard:mainas its root, is raised in tabmain, and a trustedmaindoes 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 test/test_flake_pattern_ratchet.py: 68 passed. Semgrep 1.78.0 on the diff (--baseline-commitmerge-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_approvalcallback, a realDashboardStatewith tabmain, a realSubagentManagerholdingSubagentInforecords whoseroot_session_keyfollows admission's stamping rule, and the spawn slot resolver's body over the real_spawn_parent_slot. The pending record'sslotwas read from_pending_approvals; a rejecting stand-in plays the person.Before the fix:
After the fix:
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
mainand is still approved bymain'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
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)