anomalyco / anomalyco/opencode

Task tool description ignores session permissions

Open
#48,106 1 comment 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Sep 9, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

Description

The Task tool's model-facing subagent list ignores session permissions. describeTask filters with agent.permission, while execution and the adjacent Code Mode description merge agent and session rules. A session-denied target is still advertised; a session-allowed target can remain absent.

This is a description mismatch, not a claim that execution bypasses permissions. #41100 included this fix alongside other changes but was automatically closed without merging. PR #48107 fixes session permission merging only.

Scope relative to the related issues
  • #35238 concerns the V2 subagent tool in packages/core, including runtime enforcement. This issue concerns the legacy Task description in packages/opencode/src/tool/registry.ts.
  • #45078 concerns copying superseded parent denies into a child's permissions in deriveSubagentSessionPermission. This reproduction creates no child session; the mismatch already exists in registry.tools() output.
  • #39086 reports the entire task tool missing. Here task is present, but its available-agent list includes session-denied targets or omits session-allowed targets.

The fix only supplies Permission.merge(agent.permission, session.permission ?? []) to describeTask. It changes neither rule evaluation semantics nor execution checks, child-session inheritance, or whole-tool visibility. Four session-override regression cases fail on the unmodified base and pass with #48107; omitted/empty session permissions retain their behavior.

OpenCode version

dev at 830d5eb5354874105cc31599635a80c1662609e8

Steps to reproduce
  1. Call ToolRegistry.Service.tools with an agent whose Task rules deny * and then allow explore.
  2. Pass permission: [{ permission: "task", pattern: "explore", action: "deny" }].
  3. Inspect the returned task.description: its available-agent list still includes explore; it should omit it.
  4. Conversely, a session allow or ask for general should make it visible despite the agent's wildcard deny, but currently does not.

Code: https://github.com/anomalyco/opencode/blob/830d5eb5354874105cc31599635a80c1662609e8/packages/opencode/src/tool/registry.ts#L265-L269

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.