



















@@ -4,6 +4,7 @@ import { DEFAULT_SUBAGENT_MAX_SPAWN_DEPTH } from "../config/agent-limits.js";
44import { resolveChannelGroupToolsPolicy } from "../config/group-policy.js";
55import type { OpenClawConfig } from "../config/types.openclaw.js";
66import type { AgentToolsConfig } from "../config/types.tools.js";
7+import { logWarn } from "../logger.js";
78import { normalizeAgentId } from "../routing/session-key.js";
89import {
910parseRawSessionConversationRef,
@@ -26,7 +27,11 @@ import {
2627type SubagentSessionRole,
2728} from "./subagent-capabilities.js";
2829import { isToolAllowedByPolicies, isToolAllowedByPolicyName } from "./tool-policy-match.js";
29-import { normalizeToolName } from "./tool-policy.js";
30+import {
31+mergeAlsoAllowPolicy,
32+normalizeToolName,
33+resolveToolProfilePolicy,
34+} from "./tool-policy.js";
30353136/**
3237 * Tools always denied for sub-agents regardless of depth.
@@ -367,7 +372,9 @@ function hasExplicitToolSection(section: unknown): boolean {
367372return section !== undefined && section !== null;
368373}
369374370-function resolveImplicitProfileAlsoAllow(params: {
375+/** Detect tool config sections that previously widened profiles implicitly.
376+ * Used only for migration warnings — not merged into profileAlsoAllow. #47487 */
377+function detectImplicitProfileGrants(params: {
371378globalTools?: OpenClawConfig["tools"];
372379agentTools?: AgentToolsConfig;
373380}): string[] | undefined {
@@ -422,13 +429,33 @@ export function resolveEffectiveToolPolicy(params: {
422429});
423430const explicitProfileAlsoAllow =
424431resolveExplicitProfileAlsoAllow(agentTools) ?? resolveExplicitProfileAlsoAllow(globalTools);
425-const implicitProfileAlsoAllow = resolveImplicitProfileAlsoAllow({ globalTools, agentTools });
426-const profileAlsoAllow =
427-explicitProfileAlsoAllow || implicitProfileAlsoAllow
428- ? Array.from(
429-new Set([...(explicitProfileAlsoAllow ?? []), ...(implicitProfileAlsoAllow ?? [])]),
430-)
431- : undefined;
432+433+// Warn affected users about removed implicit grants (#47487), but only when
434+// the active profile/explicit alsoAllow do not already grant those tools.
435+if (profile) {
436+const implicitGrants = detectImplicitProfileGrants({ globalTools, agentTools });
437+if (implicitGrants) {
438+const profilePolicy = mergeAlsoAllowPolicy(
439+resolveToolProfilePolicy(profile),
440+explicitProfileAlsoAllow,
441+);
442+const uncovered = implicitGrants.filter(
443+(toolName) => !isToolAllowedByPolicyName(toolName, profilePolicy),
444+);
445+if (uncovered.length > 0) {
446+logWarn(
447+`tools policy: profile "${profile}"${agentId ? ` (agent "${agentId}")` : ""} has ` +
448+`configured tool sections (tools.exec / tools.fs) that no longer implicitly widen ` +
449+`the profile. Add alsoAllow: [${uncovered.map((t) => `"${t}"`).join(", ")}] ` +
450+`explicitly if these tools should be available. See #47487.`,
451+);
452+}
453+}
454+}
455+456+const profileAlsoAllow = explicitProfileAlsoAllow
457+ ? Array.from(new Set(explicitProfileAlsoAllow))
458+ : undefined;
432459return {
433460 agentId,
434461globalPolicy: pickSandboxToolPolicy(globalTools),
@@ -437,7 +464,7 @@ export function resolveEffectiveToolPolicy(params: {
437464agentProviderPolicy: pickSandboxToolPolicy(agentProviderPolicy),
438465 profile,
439466providerProfile: agentProviderPolicy?.profile ?? providerPolicy?.profile,
440-// alsoAllow is applied at the profile stage (to avoid being filtered out early).
467+// alsoAllow is applied at the profile stage to avoid early filtering.
441468 profileAlsoAllow,
442469providerProfileAlsoAllow: Array.isArray(agentProviderPolicy?.alsoAllow)
443470 ? agentProviderPolicy?.alsoAllow
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。