Skip to content

Permission asks from nested subagent sessions silently hang #13715

Closed

Description

@ro-hansolo

Description

When a subagent spawns another subagent that requires permission (e.g. bash), the permission ask is emitted but never rendered in the TUI. The session hangs forever waiting for a response that never comes.
The children() memo in src/cli/cmd/tui/routes/session/index.tsx only collects direct child sessions. Permission and question events from grandchild sessions (sub-sub-agents) are never picked up.
Repro: have a general subagent spawn another general subagent that runs a bash command with "ask" permissions. The inner agent's permission request is invisible to the user.

Plugins

None

OpenCode version

1.2.4

Steps to reproduce

  1. Set bash permissions to "ask" for the build agent
  2. Send the prompt: Spawn a general subagent with this task: "Spawn another general subagent with this task: 'Run ls -la using bash and report the output.' Report back what it says."
  3. The innermost general subagent requests bash permission but no prompt appears in the TUI. The session hangs indefinitely

Screenshot and/or share link

Screen.Recording.2026-02-15.at.3.58.30.PM.mov

Operating System

macOS 26.1 (25B77)

Terminal

Ghostty

Activity

  1. added
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on Feb 15, 2026
  2. github-actions commented on Feb 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of an existing issue. Please check:

    Both issues appear to stem from the same root cause: the TUI only collects direct child sessions and misses events (permissions, questions) from grandchild sessions and deeper descendants. #7654 specifically mentions the same code location (children() memo in src/cli/cmd/tui/routes/session/index.tsx).

  3. feddericovonwernich commented on Apr 11, 2026

    @feddericovonwernich

    I opened a PR with a minimal fix + regression coverage for this issue:

    #21996

    I also compiled and ran this locally, and I can confirm the nested prompt surfacing issue is fixed with these changes (permissions/questions from deeper subagent descendants now surface correctly).

    I’d really appreciate getting this into mainline so I don’t have to maintain a fork to keep receiving updates.

    Thank you all for the great work on OpenCode — this project is fantastic.

    cc @thdxr @rekram1-node @adamdotdevin
    Related: #7654

  4. bernatGene commented on Apr 12, 2026

    @bernatGene

    facing the same issue.

  5. aserowy commented on Apr 22, 2026

    @aserowy

    would be awesome to get this fixed. Having the same result with question tool usage in subsubagents.

    kind regards

  6. dwen3232 commented on Apr 25, 2026

    @dwen3232

    Would also appreciate this fixed be reviewed soon. The issue is especially annoying with the Explore subagent, because it can sometimes decide to spawn its own Explore subagent

  7. Terminator637 commented on Apr 27, 2026

    @Terminator637

    Rough workaround now is to restrict general, explore and others to spawn their subagents via task, questions have the same issue #7654

    "agent": {
        "general": {
          "steps": 50,
          "permission": {
            // [BUG] Questions from nested sub-agents don't appear in TUI https://github.com/anomalyco/opencode/issues/7654
            "task": "deny",
            "question": "allow",
            "todowrite": "allow"
          }
        },
        "explore": {
          "steps": 50,
          "permission": {
            // [BUG] Questions from nested sub-agents don't appear in TUI https://github.com/anomalyco/opencode/issues/7654
            "task": "deny",
            "question": "allow",
            "todowrite": "allow"
          }
        }
      },
  8. removed
    bugSomething isn't working
    opentuiThis relates to changes in v1.0, now that opencode uses opentui
    on May 3, 2026
  9. mguttmann commented on Jun 13, 2026

    @mguttmann

    This is addressed in PR #32167 (proposal #32166). Permission asks raised anywhere in a nested tree are now routed to the root session (carrying originSessionID/originAgent/originDepth metadata), and the headless run loop's permission filter was made tree-aware — so an ask from a grandchild no longer hangs forever. There's a regression test for the root-routing case.

  10. CodeAnimal commented on Jul 24, 2026

    @CodeAnimal

    This is a significant issue when using nested subagents, with a PR that apparently resolves it. It would be great if we can get this fix in ASAP.

  11. trin4ik commented on Jul 30, 2026

    @trin4ik

    Still reproducible on OpenCode 1.18.7 / macOS 26.2 with the question tool, not only permission asks: a depth-2 subagent's question does not reach the root TUI, leaving the workflow silently stalled.

    This descendant prompt routing must also be fixed in opencode2. See also #39112 for a current depth-2 reproduction.

  12. samiralibabic commented on Aug 3, 2026

    @samiralibabic

    I traced the current implementation and the PRs linked to this issue.

    The bug is still reproducible on OpenCode 1.18.7 in #39112. The server correctly creates the nested permission/question request, but Permission.ask() then waits indefinitely for a reply. The current TUI only selects requests from the root session and its direct children, so requests from grandchildren can remain invisible.

    The web/desktop app already handles this differently: it traverses the complete descendant tree through sessionTreeRequest(). The TUI and some other clients still assume one level of children.

    There are now several overlapping implementations, particularly #30639 and #36046, but I could not find a submitted maintainer review choosing the intended architecture.

    Could a maintainer clarify the desired request-routing contract?

    1. Preserve the leaf sessionID, and make clients use shared ancestry/subtree handling to determine which root or managed session presents the request; or
    2. Route the request to the root/managed ancestor in core and carry the actual origin separately through metadata such as originSessionID, originAgent, and originDepth.

    My preference would be to preserve the actual requester in sessionID and add a separate core-computed presentation/owner session ID. That preserves provenance while avoiding independent tree traversal in every client.

    An explicit decision would clarify whether #30639, #36046, or a smaller extracted implementation is the preferred path.

  13. upiscium commented on Aug 9, 2026

    @upiscium

    Confirmed with a deterministic depth-2 Bash permission reproduction on OpenCode 1.18.4 / Linux. This is still reproducible without a provider or child-session stall.

    Topology:

    root build session (openai/gpt-5.6-sol)
      -> task-orchestrator (openai/gpt-5.3-codex-spark)
        -> general leaf (openai/gpt-5.6-luna)
          -> Bash permission ask
    

    Controls and observations:

    • Direct general leaf provider/tool execution: PASS.

    • Depth-2 ask-free general leaf running git status --short: PASS; the leaf returned to its parent.

    • The Ask fixture disabled the unrelated question tool for the leaf (question: deny, resolved as tools.question: false) while leaving Bash at its normal ask boundary.

    • The leaf immediately requested exactly:

      printf 'depth2-ask-approved\n'
    • Debug evidence recorded permission evaluation as action=ask, followed by creation of a permission.asked request for the depth-2 leaf.

    • The root/Main TUI never displayed a permission prompt. It only remained on the pending child task, so the request could not be approved or rejected from the Main TUI.

    • Waiting did not produce a resolution event; the leaf and its parents remained blocked on the pending permission.

    This isolates the stop point to:

    depth-2 permission.asked emitted
      -> root/Main TUI descendant request discovery or presentation  [missing]
    

    It is not a model/provider stall and is distinct from the earlier question-tool ambiguity because the question tool was unavailable in this run. Navigating to a child session to approve would not satisfy the centralized root-TUI permission contract.

    Local tracking and diagnostic procedure: upiscium/KUMIKI#41

  14. BenGoetemann commented on Aug 11, 2026

    @BenGoetemann

    Can confirm. I have the same issue with Version 1.18.16. please fix.

  15. mmadariaga commented on Aug 21, 2026

    @mmadariaga

    @rekram1-node we need this fixed, please

  16. apkrymov commented on Aug 25, 2026

    @apkrymov

    @thdxr @rekram1-node
    This is a complete blocker for subagent workflows. Any suggested community fix or workaround would be much appreciated

  17. GamingInfinite commented on Sep 16, 2026

    @GamingInfinite

    I've literally written into my Agents.md on my projects where i use opencode for it to specifically not use subagents because of this issue, specifically in Zed's AI panel agent, so if this could get fixed that'd be awesome.

  18. mmadariaga commented on Sep 16, 2026

    @mmadariaga

    It looks like the error is fixed in v2.0.3

  19. neriousy commented on Oct 1, 2026

    @neriousy
    Member

    In OpenCode v2, the session view gathers pending permission requests from every session in the family, including subagents started by other subagents. Nested requests now appear in the TUI instead of hanging silently.

    Added in 02cb350 and ce228bf. It was reverted once and restored in #46376. A commenter here confirmed it works in v2.0.3.

    Closing as completed. If you still see a nested permission hang on v2, please open a new issue with steps to reproduce.

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

Metadata

Metadata

Assignees

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