@@ -27,7 +27,11 @@ import {
2727 type SubagentSessionRole ,
2828} from "./subagent-capabilities.js" ;
2929import { isToolAllowedByPolicies , isToolAllowedByPolicyName } from "./tool-policy-match.js" ;
30- import { normalizeToolName } from "./tool-policy.js" ;
30+ import {
31+ mergeAlsoAllowPolicy ,
32+ normalizeToolName ,
33+ resolveToolProfilePolicy ,
34+ } from "./tool-policy.js" ;
3135
3236/**
3337 * Tools always denied for sub-agents regardless of depth.
@@ -426,12 +430,18 @@ export function resolveEffectiveToolPolicy(params: {
426430 const explicitProfileAlsoAllow =
427431 resolveExplicitProfileAlsoAllow ( agentTools ) ?? resolveExplicitProfileAlsoAllow ( globalTools ) ;
428432
429- // Warn affected users about removed implicit grants (#47487).
433+ // Warn affected users about removed implicit grants (#47487), but only when
434+ // the active profile/explicit alsoAllow do not already grant those tools.
430435 if ( profile ) {
431436 const implicitGrants = detectImplicitProfileGrants ( { globalTools, agentTools } ) ;
432437 if ( implicitGrants ) {
433- const alreadyCovered = new Set ( explicitProfileAlsoAllow ?? [ ] ) ;
434- const uncovered = implicitGrants . filter ( ( t ) => ! alreadyCovered . has ( t ) ) ;
438+ const profilePolicy = mergeAlsoAllowPolicy (
439+ resolveToolProfilePolicy ( profile ) ,
440+ explicitProfileAlsoAllow ,
441+ ) ;
442+ const uncovered = implicitGrants . filter (
443+ ( toolName ) => ! isToolAllowedByPolicyName ( toolName , profilePolicy ) ,
444+ ) ;
435445 if ( uncovered . length > 0 ) {
436446 logWarn (
437447 `tools policy: profile "${ profile } "${ agentId ? ` (agent "${ agentId } ")` : "" } has ` +
0 commit comments