Skip to content

fix(opencode): enforce per-target task subagent permissions - #41100

Closed
686f6c61 wants to merge 1 commit into
anomalyco:devfrom
686f6c61:subagent-permissions
Closed

686f6c61 wants to merge 1 commit into
anomalyco:devfrom
686f6c61:subagent-permissions

Conversation

@686f6c61

@686f6c61 686f6c61 commented Aug 7, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #35238

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Per-target task permission rules (for example allow only explore) were not a hard runtime boundary when the model invented a denied subagent_type, and model-facing task guidance only considered agent rules, not session permission ceilings.

This change:

  1. Filters the task tool description using Permission.merge(agent.permission, session.permission) and hides primary/hidden agents.
  2. Rejects primary-mode targets at execute time (they are not delegatable subagents).
  3. Hard-denies denied subagent_type values before ctx.ask and before creating a child session, so inventing a name still fails closed.

bypassAgentCheck (explicit user @agent routing) is unchanged.

How did you verify your code works?

cd packages/opencode
bun test test/tool/task.test.ts test/permission-task.test.ts
# 44 pass, 0 fail

New coverage:

  1. description applies session permission ceilings
  2. execute rejects denied subagent_type without a child session
  3. execute rejects primary agents as task targets

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Reject denied and primary subagent_type targets at execute time, and align
task tool guidance with agent plus session permission ceilings so the model
only sees allow/ask targets.
@github-actions

github-actions Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Automated PR Cleanup

Thank you for contributing to opencode.

Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions.

This PR was closed because it matched the following cleanup criteria:

  • The PR was created more than 1 month ago
  • The PR had fewer than 2 positive reactions
  • Positive reactions are counted as thumbs-up, heart, celebration, or rocket reactions on the PR

PRs created within the last month are not affected by this cleanup.

If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate.

Thanks again for taking the time to contribute.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

V2 subagent tool does not enforce per-target subagent permissions

1 participant