anomalyco / anomalyco/opencode
Task subagents inherit parent session denies that later rules superseded
@rekram1-node is already working on this.
Since Aug 25, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Describe the bug
deriveSubagentSessionPermission copies every parent-session deny rule into a task subagent's session, ignoring rule order. Session permission rules are append-only and evaluated last-match-wins, so a parent whose history is:
[
{ "permission": "bash", "pattern": "*", "action": "deny" },
{ "permission": "bash", "pattern": "*", "action": "allow" }
]
is effectively allowed to run bash — but every new task subagent it spawns receives only the stale bash deny. The parent can work; all of its future children are permanently denied, even when the subagent's own agent policy allows bash.
This bites any client that implements a plan-style restriction by appending session denies and later restores access by appending allows (PATCH is append-only; there is no rule-removal API). Once a session has ever been restricted, it can never again delegate mutating work.
Steps to reproduce
On 1.18.22 (also present on current dev):
- Create a session.
PATCH /session/{id}withpermission: [{bash,*,deny}].PATCH /session/{id}withpermission: [{bash,*,deny},{bash,*,allow}](append-only restore).- Confirm the parent itself can run bash.
- Prompt the parent to delegate a bash command via the
tasktool. - Inspect the child session's
permission: it contains{bash,*,deny}. The child's bash calls are denied.
Expected behavior
Only denies that are still part of the parent's effective ceiling should be inherited. A deny that a later rule supersedes for the same permission and pattern is no longer the parent's effective action and should not pin the child.
Environment
- opencode 1.18.22, macOS arm64, verified unchanged at
devHEAD packages/opencode/src/agent/subagent-permissions.ts(rule.action === "deny"filter keeps every deny regardless of later rules)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.