fix(policy): preserve optional tool opt-ins for allow-all configs

This commit is contained in:
Agustin Rivera 2026-03-31 17:40:37 +00:00
parent 236a510060
commit c58da46bb4
3 changed files with 13 additions and 2 deletions

View File

@ -39,7 +39,7 @@ describe("pickSandboxToolPolicy", () => {
alsoAllow: ["web_search"],
}),
).toEqual({
allow: [],
allow: ["*", "web_search"],
deny: undefined,
});
});

View File

@ -14,7 +14,7 @@ function unionAllow(base?: string[], extra?: string[]): string[] | undefined {
return Array.from(new Set(["*", ...extra]));
}
if (base.length === 0) {
return base;
return Array.from(new Set(["*", ...extra]));
}
return Array.from(new Set([...base, ...extra]));
}

View File

@ -5,6 +5,7 @@ import type { SandboxToolPolicy } from "./sandbox/types.js";
import { TOOL_POLICY_CONFORMANCE } from "./tool-policy.conformance.js";
import {
applyOwnerOnlyToolPolicy,
collectExplicitAllowlist,
expandToolGroups,
isOwnerOnlyToolName,
normalizeToolName,
@ -109,6 +110,16 @@ describe("tool-policy", () => {
expect(applyOwnerOnlyToolPolicy(tools, true)).toHaveLength(1);
});
it("preserves explicit alsoAllow hints when allow is empty", () => {
expect(
collectExplicitAllowlist([
{
allow: ["*", "optional-demo"],
},
]),
).toContain("optional-demo");
});
it("strips nodes for non-owner senders via fallback policy", () => {
const tools = [
{