| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Subagent sessions created by TaskTool did not inherit the parent session's deny rules (question, plan_enter, plan_exit), causing opencode run to hang indefinitely when a subagent invoked the question tool. Three changes fix this: 1. task.ts: Propagate parent session deny rules to subagent sessions so question/plan permissions are inherited. 2. prompt.ts: Merge tool-derived permissions with existing session permissions instead of replacing them, which was silently discarding the inherited deny rules. 3. run.ts: Remove sessionID filter from permission.asked handler so subagent permission requests are also auto-rejected as a safety net.
|
Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR. |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
Summary
Fixes opencode run hanging indefinitely when a subagent (e.g. @explore) invokes the question tool in non-interactive mode.
Fixes #11899, #10012
Related: #9554, #8852, #10746, #11932
Problem
When opencode run creates a session, it correctly sets question: deny, plan_enter: deny, and plan_exit: deny permission rules on the main session. However, subagent sessions created by TaskTool did not inherit these deny rules, so:
Additionally, SessionPrompt.prompt() overwrote the session's permission array with tool-derived permissions instead of merging, which discarded any inherited deny rules even if they were correctly propagated.
Changes
Three minimal changes fix this:
packages/opencode/src/tool/task.ts — Propagate the parent session's deny rules to subagent sessions. Before creating a child session, fetch the parent session and include its deny rules in the subagent's permission array.
packages/opencode/src/session/prompt.ts — Merge tool-derived permissions with existing session permissions instead of replacing them. The backwards-compat tools field handling was overwriting session.permission with only the tool deny/allow rules, silently discarding inherited deny rules from the parent session.
packages/opencode/src/cli/cmd/run.ts — Remove the sessionID filter from the permission.asked event handler so that permission requests from subagent sessions are also auto-rejected. This serves as a safety net. The session.error and session.status handlers retain their session ID filters since those should only apply to the main session.
How I verified this works
Root cause analysis
The permission system uses findLast (last-match-wins) across a merged ruleset. run.ts sets deny rules on the main session, but TaskTool created subagent sessions with a hardcoded permission array that only included todowrite, todoread, and conditionally task deny rules — never propagating the parent's question/plan_enter/plan_exit deny rules. Even if the rules had been propagated to the session creation, SessionPrompt.prompt() would overwrite them when converting the tools parameter to permission rules.
Related PRs