GeezerVison is showing github.com — fix(task): respect subagent explicit edit:allow over inherited parent edit:deny by public-static-void · Pull Request #29235 · anomalyco/opencode
Conversation
Issue for this PR
Closes #26514
Closes #26700
Type of change
What does this PR do?
Fixes the interaction between #26514 (Plan Mode bypass) and #26700 (parent denies over-constrain subagents).
Subagents with an explicit write: allow (or edit: allow) configuration can now actually use edit-class tools, even when their parent agent has edit: deny (Plan Mode). Generic subagents without an explicit edit-class allow still inherit the parent's denies. Plan Mode security is preserved.
Three changes:
fromConfig() aliases write/apply_patch to the edit permission key (packages/opencode/src/permission/index.ts). The runtime already treats write, apply_patch, and edit as the same tool class via EDIT_TOOLS, but the config layer stored write: allow as permission: "write" which is invisible to the "edit" lookup. Aliasing makes config consistent with runtime.
deriveSubagentSessionPermission() skips parent edit: deny when the subagent has explicit edit: allow (packages/opencode/src/agent/subagent-permissions.ts). PR fix(task): subagent inherits parent agent's deny rules (Plan Mode security bypass) #26597 forwarded all parent edit denies to subagents. PR fix(task): preserve subagent self permissions #27201 narrowed it to only edit denies. This extends the same principle: if the subagent explicitly allows edit tools, the inherited deny is suppressed. Generic subagents without explicit edit rules still inherit the parent deny so Plan Mode stays secure.
prompt() merges tool-level denies instead of overwriting session permission (packages/opencode/src/session/prompt.ts). The task tool calls ops.prompt() with tool-level denies for todowrite/task/primary_tools. prompt() was overwriting session.permission, destroying inherited rules including the Plan Mode edit: deny that deriveSubagentSessionPermission() just set up. This fix uses [...session.permission, ...permissions] instead of session.permission = permissions.
This is more complete than the similar PR #27654 which only covers fix 2.
The fromConfig() aliasing and prompt.ts merge are needed too.
This fix is also complementary to the approach in #24293 which propagated parent session permissions to subagents (enabling inheritance), while this PR adds the explicit allow check on top of that (allowing overrides when the subagent opts in).
How did you verify your code works?
All upstream test scenarios pass:
- Plan Mode + generic subagent:
edit: deny inherited, tools blocked
- Plan Mode + subagent with
write: allow: edit: allow overrides, tools available
- Deny-by-default parent + capable subagent: subagent explicit allows work
- Controller/executor delegation (PR fix(task): preserve subagent self permissions #27201 test): passes
Screenshots / recordings
N/A, no UI changes.
Checklist
- I have tested my changes locally
- I have not included unrelated changes in this PR
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
… edit:deny
Three changes that together allow a subagent's explicit edit-class
configuration to override inherited parent restrictions:
1. fromConfig() aliases write/apply_patch to the edit permission key
(packages/opencode/src/permission/index.ts)
The runtime layer already treats write, apply_patch, and edit as the
same tool class via EDIT_TOOLS in core/src/permission.ts, but the
config layer stored write: allow as permission: write, invisible to
the edit lookup. Aliasing in fromConfig makes the config layer
consistent with the runtime.
2. deriveSubagentSessionPermission skips parent edit denies when
subagent explicitly allows edit-class tools
(packages/opencode/src/agent/subagent-permissions.ts)
PR anomalyco#26597 forwarded all parent agent denies to subagents (Plan Mode
security). PR anomalyco#27201 scoped this to only edit denies. This change
extends the same principle: if the subagent has explicit edit:allow
(or write:allow via fix anomalyco#1), the inherited edit:deny is suppressed.
The subagent's explicit config represents user intent and overrides
inherited restrictions. Plan Mode's edit:deny still cascades to
subagents without an explicit edit:allow.
3. prompt() merges tool-level denies into session permission instead
of overwriting (packages/opencode/src/session/prompt.ts)
The task tool calls ops.prompt() with tool-level denies for
todowrite/task/primary_tools. prompt() was overwriting the entire
session.permission, destroying any inherited rules (including the
Plan Mode edit:deny that deriveSubagentSessionPermission just set
up). This fix merges instead of replaces, preserving session-level
permission integrity.
Fixes the interaction between issues anomalyco#26514 (Plan Mode bypass)
and anomalyco#26700 (parent denies over-constrain subagents).
|
The following comment was made by an LLM, it may be inaccurate:
Based on my search, I found one related PR that appears to be addressing a very similar issue:
Related PR:
This PR appears to directly address the same core issue: ensuring that a subagent's explicit edit:allow configuration takes precedence over a parent agent's edit:deny. It's likely either a prior attempt at the same fix, a related issue that was separately worked on, or potentially a duplicate effort.
I also found:
The first match (#27654) is the most concerning as a potential duplicate since it has an almost identical title and purpose.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
This was referenced May 28, 2026
|
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.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
|
Please reopen this PR. It was auto-closed by the cleanup bot due to lack of review/activity on the PR, not because the issue is resolved or the fix is incomplete. The fix was already implemented and is still needed.
|
Sorry, something went wrong.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Assignees
No one assigned
Milestone
No milestone
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
|