Commit 1adf95c
fix(task): enforce permission checks for subagent-to-subagent delegation
Fixes a critical bug where bypassAgentCheck flag (set when user invokes
agents with @ or when prompt resolution creates agent parts) was propagating
to Task tool calls made BY subagents, causing permission rules to be ignored.
Root cause:
- When Task tool creates a subagent session, resolvePromptParts() may create
"agent" type parts if prompt contains unresolved {file:...} references
- This triggers bypassAgentCheck=true for the entire subagent session
- All subsequent Task calls by that subagent bypass permission checks
Fix:
- Move isSubagent check before permission check
- Always enforce permissions when caller is a subagent, even if
bypassAgentCheck is set
- Preserves OpenCode's intended behavior: user @ invocation can bypass,
but subagent-to-subagent delegation always checks permissions
Impact:
- Subagent permission.task rules now work correctly
- User @ invocation bypass still works (OpenCode behavior preserved)
- Fixes reported issue: assistant-sonnet could task any agent despite
permission rules denying it
Tests: 6/6 passing
Typecheck: Clean
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>1 parent 7e3e5a7 commit 1adf95c
1 file changed
+6
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
62 | 66 | | |
63 | | - | |
| 67 | + | |
| 68 | + | |
64 | 69 | | |
65 | 70 | | |
66 | 71 | | |
| |||
75 | 80 | | |
76 | 81 | | |
77 | 82 | | |
78 | | - | |
79 | | - | |
80 | | - | |
81 | | - | |
82 | 83 | | |
83 | 84 | | |
84 | 85 | | |
| |||
0 commit comments