Skip to content

Depth-2 subagent questions are dropped by the same non-root bail-out as permissions (questions() in routes/session/index.tsx) #49342

Closed as not planned

Description

@balerdis

Description

questions() in the TUI session route carries the identical defect reported for permissions in #39112: it returns [] for any non-root view, and it only ever reads the direct children of the viewed session. A question raised by a subagent at depth >= 2 is therefore never rendered in any view, and — as in the permission case — there is no timeout, so the turn hangs until the session is killed.

Filing this separately from #39112 so that a fix for permissions does not ship without it. #30635 was closed having fixed a single level of nesting, which is why #39112, #43996 and #44747 are all still open; questions() looks like the next half-fix waiting to happen.

Honesty about how this was found: by reading the source while investigating #39112, which I did reproduce. I have not executed the questions() path at runtime. The two memos are three lines apart and structurally identical, so I am reporting it rather than sitting on it, but please treat the repro steps below as derived, not executed.

Reachability: this needs explicit configuration. The global default is question: "deny" (packages/opencode/src/agent/agent.ts), and only the build and plan primaries get question: "allow". You need a subagent granted question, plus subagent_depth >= 2. That is the same shape of prerequisite as #39112 itself.

Source (v1.18.31)

packages/tui/src/routes/session/index.tsx:

const children = createMemo(() => {
  const parentID = session()?.parentID ?? session()?.id
  return sync.data.session
    .filter((x) => x.parentID === parentID || x.id === parentID)   // direct children only
    .toSorted((a, b) => (a.id < b.id ? -1 : a.id > b.id ? 1 : 0))
})
const permissions = createMemo(() => {
  if (session()?.parentID) return []                                // <- #39112
  return children().flatMap((x) => sync.data.permission[x.id] ?? [])
})
const questions = createMemo(() => {
  if (session()?.parentID) return []                                // <- this issue
  return children().flatMap((x) => sync.data.question[x.id] ?? [])
})

Two defects compound in both memos:

  1. children() collects direct children only — one level, not a recursive descendant walk. Viewed from the root it holds level-1 sessions, so a level-2 session id is never in the list.
  2. Each memo bails out entirely whenever session()?.parentID is truthy, i.e. from any non-root view — so navigating into the subagent view does not help either.

The data itself arrives and is stored correctly: packages/tui/src/context/sync.tsx keys it by the asking session's own id, and question.asked is published without a session filter (packages/opencode/src/question/index.ts). Nothing upstream of the render layer drops it.

Steps to reproduce

(Derived from source, not executed — see the note above.)

  1. Set subagent_depth: 2 or higher in opencode.json.
  2. Grant a subagent both task (so it can spawn) and question.
  3. Have it spawn a second-level subagent that is also granted question.
  4. Have the level-2 agent ask a question.

Expected: the question surfaces to the user. Actual (predicted from the code above): no dialog renders in any view and the turn does not complete.

OpenCode version

1.18.31

Suggested fix

The same patch that fixes #39112 should cover this: make children() walk descendants recursively instead of one level, and drop the if (session()?.parentID) return [] bail-out from both permissions() and questions().

Routing a nested request up to an ancestor the UI already knows about would work too, but note that PermissionV1.Request (packages/schema/src/v1/permission.ts) carries only sessionID — no parentID or rootID — so the view currently has nothing to walk up with.

Operating System

Linux

Terminal

zellij

Activity

  1. thdxr commented on Oct 11, 2026

    @thdxr
    Member

    Thanks for the report! OpenCode 2.0 is now out and development is focused on V2, so we're closing issues filed against OpenCode 1. Please upgrade (opencode upgrade --major, details: https://anoma.ly/notes/opencode-2-0), and if this is still relevant on 2.0, reopen this issue or open a new one with your 2.0 version.

    — from 𝕺𝖕𝖊𝖓𝕮𝖔𝖉𝖊

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