fix(cli): fail headless subagent permission asks instead of hanging - #11923
Merged
Conversation
marius-kilocode
enabled auto-merge
July 3, 2026 15:44
chrarnoldus
approved these changes
Jul 3, 2026
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)CRITICAL
Files Reviewed (5 files)
Fix these issues in Kilo Cloud Reviewed by claude-sonnet-5-20260630 · Input: 76 · Output: 26K · Cached: 3M Review guidance: REVIEW.md from base branch |
marius-kilocode
disabled auto-merge
July 3, 2026 15:53
Collaborator
Author
|
Remaining known gaps, both acceptable: Daemon mode inherits the same event-ordering assumption as --auto (metadata before child ask) — not new risk |
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
…rmission-hang fix(cli): fail headless subagent permission asks instead of hanging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sync subagents spawned via the task tool hang forever in headless
kilo runwhen they hit a permissionaskrule.Permission.askblocks on a deferred until aPermission.replyarrives, but the headless run loop only answers permission requests for the root session, so a child-session ask waits for a reply that never comes. Reproduced withpermission: { "bash": "ask" }and a prompt that spawns a subagent running a bash command: the run stalls indefinitely after the task starts.The deny decision is a property of the run context, not the agent definition: interactive clients (TUI, VS Code extension) surface child-session permission prompts on the parent session view and users answer them today, so subagent asks must keep queuing there. Agents with
mode: "all"are also valid subagents, so keying offagent.mode === "subagent"would both miss those and not distinguish interactive from headless runs.Two complementary mechanisms, because
kilo runcan evaluate permissions in-process (embedded server) or in another process (daemon attach,--attach):kilo runmarks its root session in a Kilo-ownedKiloHeadlessregistry. When a permission request from a descendant of a marked root would queue,Permission.askfails it immediately withDeniedError. The guard sits at the single enforcement point inPermission.ask, so every ask path is covered (tool asks, MCP tool asks, the doom-loop guard) without threading a flag through callers.--autoalready uses. Task children are tracked unconditionally; in plain headless mode their asks are rejected with a visibleauto-rejectingnotice, and under--dangerously-skip-permissionsthey are approved, matching what that flag already does for the root session (previously child asks hung there too).Other behavior:
--autobehavior is unchanged; it already approves tracked child asks, so headless marking is skipped for it.Shared upstream files are touched minimally: one marked guard block plus an import in
permission/index.ts, and marked additions incli/cmd/run.ts. The registry and parent resolution live in the new Kilo-ownedsrc/kilocode/permission/headless.ts.Verified manually with
permission: { "bash": "ask" }and a prompt that spawns a bash-running subagent: the run hangs on v7.3.54 until externally killed; with this fix it completes in seconds in embedded mode (server-side deny) and in--attachmode against a separatekilo serveprocess (wire-level reject with the auto-rejecting notice).Fixes #11903. Supersedes #11916, which keyed the deny off
agent.mode === "subagent"and therefore missedmode: "all"subagents, denied prompts interactive users can answer today, and left the doom-loop ask path uncovered.