fix(plan): deny plan_exit tool in subagent sessions#27887
Open
BYK wants to merge 1 commit into
Open
Conversation
Subagents spawned via the task tool could call plan_exit because the tools map passed to SessionPrompt.prompt() did not include plan_exit: false. Since SessionPrompt.prompt() overwrites session permissions with the tools map, the deny rules set via deriveSubagentSessionPermission were silently overridden. Add plan_exit: false to the tools map so the deny persists through the prompt permission rewrite.
Contributor
|
Thanks for updating your PR! It now meets our contributing guidelines. 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Issue for this PR
Closes #27886, partially addresses #18515
Type of change
What does this PR do?
Subagents spawned via the
tasktool could callplan_exitbecause thetoolsmap passed toSessionPrompt.prompt()did not includeplan_exit: false. SinceSessionPrompt.prompt()overwrites session permissions with the tools map, the deny rules set viaderiveSubagentSessionPermission()were silently overridden.This adds
plan_exit: falseto the tools map intask.tsso the deny persists through the prompt permission rewrite.This is a re-filing of #21866 which was auto-closed by the cleanup bot.
How did you verify your code works?
The fix is a one-line addition to the tools map. Verified by code inspection that the
toolsmap now includesplan_exit: false, which prevents subagents from calling theplan_exittool. The existing test intest/agent/plan-mode-subagent-bypass.test.tscovers the relatedderiveSubagentSessionPermissionlogic at the session permission level.Screenshots / recordings
N/A — backend-only change.
Checklist