You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Subagent agent name is not persisted, so nested subagents lose inherited permission restrictions #30610
When the task tool creates a subagent session it does not store the agent name on the new session row. If that subagent spawns its own subagent, the permission resolver reads parent.agent to inherit the parent's restrictions, finds it empty, and drops the parent agent's edit denies on the grandchild.
The practical effect: a Plan-mode subagent that spawns another subagent ends up with a grandchild that can edit files, even though Plan mode forbids edits.
This is a different root cause from #30527, which is about prompt-time setPermission replacing instead of merging the ruleset. Here the agent column is never written at session creation, so deriveSubagentSessionPermission has nothing to read. Same code area as #26597, #26700, and #26747.
I have a fix that sets the agent name when the subagent session is created.
Plugins
None
OpenCode version
1.15.13
Steps to reproduce
Use an agent whose permissions deny edits (for example Plan mode).
Have it spawn a subagent via the task tool, and have that subagent spawn another subagent.
The deepest subagent is allowed to edit, because the deny was not inherited.
changed the title [-]Nested subagents don't inherit the parent agent's permission restrictions[/-][+]Subagent `agent` name is not persisted, so nested subagents lose inherited permission restrictions[/+]on Jun 3, 2026
Resolved on dev: tool/task.ts:151/:200 now set agent: next.name on the subagent session, so nested subagents inherit the parent agent's restrictions. Closing.
Activity
literally-dan commentedon Jun 3, 2026
Closing this, I opened it before it was ready for review. I'll reopen once I've gone over it properly.
[-]Nested subagents don't inherit the parent agent's permission restrictions[/-][+]Subagent `agent` name is not persisted, so nested subagents lose inherited permission restrictions[/+]literally-dan commentedon Jun 9, 2026
Resolved on
dev:tool/task.ts:151/:200now setagent: next.nameon the subagent session, so nested subagents inherit the parent agent's restrictions. Closing.