Repository navigation
feat(core): Disallow plan lifecycle tools in subagents #6087
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
e0dee64
feat(core): Restrict subagent plan mode tools
doudouOUC 539c877
codex: address PR review feedback (#6087)
doudouOUC 585aa25
codex: address follow-up PR review feedback (#6087)
doudouOUC 2efcd91
codex: address plan tool observability feedback (#6087)
doudouOUC 0a62a85
codex: address PR review feedback (#6087)
doudouOUC 1bb8db8
codex: address PR review feedback (#6087)
doudouOUC d8a3730
codex: address PR review feedback (#6087)
doudouOUC d0670df
codex: address PR review feedback (#6087)
doudouOUC 476ec7a
codex: address PR review feedback (#6087)
doudouOUC 93d69db
codex: address PR review feedback (#6087)
doudouOUC 80695fc
codex: address PR review feedback (#6087)
doudouOUC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
36 changes: 36 additions & 0 deletions
36
packages/core/src/agents/runtime/subagent-plan-tool-policy.ts
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| /** | ||
| * @license | ||
| * Copyright 2025 Qwen | ||
| * SPDX-License-Identifier: Apache-2.0 | ||
| */ | ||
|
|
||
| import { ToolNames } from '../../tools/tool-names.js'; | ||
| import { isTeammate } from '../team/identity.js'; | ||
| import { getCurrentAgentId } from './agent-context.js'; | ||
|
|
||
| export const SUBAGENT_PLAN_LIFECYCLE_TOOLS: ReadonlySet<string> = new Set([ | ||
| ToolNames.ENTER_PLAN_MODE, | ||
| ToolNames.EXIT_PLAN_MODE, | ||
| ]); | ||
|
|
||
| export function isSubagentLikeExecutionContext(): boolean { | ||
| return getCurrentAgentId() !== null || isTeammate(); | ||
| } | ||
|
|
||
| export function isSubagentPlanLifecycleTool(toolName: string): boolean { | ||
| return SUBAGENT_PLAN_LIFECYCLE_TOOLS.has(toolName); | ||
| } | ||
|
|
||
| export function isPlanLifecycleToolUnavailableInSubagent( | ||
| toolName: string, | ||
| ): boolean { | ||
| return ( | ||
| isSubagentLikeExecutionContext() && isSubagentPlanLifecycleTool(toolName) | ||
| ); | ||
| } | ||
|
|
||
| export function getSubagentPlanToolUnavailableMessage( | ||
| toolName: string, | ||
| ): string { | ||
| return `${toolName} is not available inside subagents or team agents. Plan mode is owned by the caller/main session; return your plan, findings, or constraints to the caller in your normal response instead of entering or exiting plan mode.`; | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.