Skip to content

fix: subagent permission asks hang indefinitely (sync subagents treated as interactive) #35073

Closed as not planned

Description

@Ivaloz

Description

Sync subagents (spawned via actor tool with action: "run") hang indefinitely when they trigger a permission ask. The permission prompt is never surfaced to the user because the subagent is treated as an interactive actor waiting for user confirmation, but no human is attached to reply.

Root Cause

In session/prompt.ts, the askNonInteractive check only marks actors as non-interactive if:

  1. They are in SYSTEM_SPAWNED_AGENT_TYPES (checkpoint-writer, dream, distill), OR
  2. They have background: true (only set for spawn action)

Sync subagents (run action) have background: false and are not in SYSTEM_SPAWNED_AGENT_TYPES, so they are treated as interactive. When they hit a permission ask, the system waits for a user reply that never comes.

Proposed Fix

All subagents should be marked as non-interactive because they have no attached human:

const askNonInteractive = askActor
  ? SYSTEM_SPAWNED_AGENT_TYPES.has(askActor.agent) || askActor.background || askActor.mode === "subagent"
  : SYSTEM_SPAWNED_AGENT_TYPES.has(input.agent.name)

This ensures sync subagents fail clean with DeniedError instead of hanging forever.

Related Issues

MiMo Code Reference

This fix has been implemented in MiMo Code PR #1537: XiaomiMiMo/MiMo-Code#1537

Environment

  • OpenCode version: 1.17.8
  • OS: Windows 11
  • Terminal: PowerShell

Steps to Reproduce

  1. Set bash permissions to "ask" for the build agent
  2. Spawn a sync subagent that runs a bash command
  3. The subagent hangs forever waiting for permission confirmation that never comes

Activity

  1. labulalala commented on Jul 5, 2026

    @labulalala

    Related scenario that I believe is the same root cause but with a different policy expectation: --auto (auto-approve) does not propagate from the parent session to subagent sessions.

    Reproduce:

    1. Start opencode with --auto (or with "Auto Approve Permission" enabled).
    2. Have the primary agent spawn a subagent (via the task/actor tool) that triggers a tool permission ask (e.g. a bash command not on the allow-list).
    3. The subagent hangs indefinitely — the parent's --auto / auto-approve setting is not inherited, so the subagent waits for a human that isn't attached.

    Why this matters beyond the reported hang:
    The proposed fix in this issue (mark askActor.mode === "subagent" as non-interactive → fail with DeniedError) would resolve the hang, but for the --auto case it would turn a should-auto-approve path into a hard deny. The desired behavior when the parent session is in --auto mode is for the subagent to inherit the auto-approve setting and proceed, not to deny-and-fail.

    Suggestion: when resolving the non-interactive classification, also propagate the parent session's approval mode (auto-approve / --auto) into the subagent session, so:

    • parent --auto ON → subagent auto-approves (no hang, no deny)
    • parent --auto OFF → subagent fails clean with DeniedError (current proposed behavior)

    Possibly related: #13715 (nested subagent permission asks also hang), #32388 (ACP variant).

  2. github-actions commented on Sep 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions