This commit is contained in:
Ashwin Bhat
2025-05-27 17:06:57 -07:00
parent f93fbb32ec
commit f18a16aa0f
2 changed files with 19 additions and 9 deletions

View File

@@ -64,8 +64,12 @@ export function buildDisallowedToolsString(
// If user has explicitly allowed some hardcoded disallowed tools, remove them from disallowed list // If user has explicitly allowed some hardcoded disallowed tools, remove them from disallowed list
if (allowedTools) { if (allowedTools) {
const allowedToolsArray = allowedTools.split(",").map(tool => tool.trim()); const allowedToolsArray = allowedTools
disallowedTools = disallowedTools.filter(tool => !allowedToolsArray.includes(tool)); .split(",")
.map((tool) => tool.trim());
disallowedTools = disallowedTools.filter(
(tool) => !allowedToolsArray.includes(tool),
);
} }
let allDisallowedTools = disallowedTools.join(","); let allDisallowedTools = disallowedTools.join(",");

View File

@@ -726,7 +726,10 @@ describe("buildDisallowedToolsString", () => {
test("should remove hardcoded disallowed tools if they are in allowed tools", () => { test("should remove hardcoded disallowed tools if they are in allowed tools", () => {
const customDisallowedTools = "BadTool1,BadTool2"; const customDisallowedTools = "BadTool1,BadTool2";
const allowedTools = "WebSearch,SomeOtherTool"; const allowedTools = "WebSearch,SomeOtherTool";
const result = buildDisallowedToolsString(customDisallowedTools, allowedTools); const result = buildDisallowedToolsString(
customDisallowedTools,
allowedTools,
);
// WebSearch should be removed from disallowed since it's in allowed // WebSearch should be removed from disallowed since it's in allowed
expect(result).not.toContain("WebSearch"); expect(result).not.toContain("WebSearch");
@@ -754,7 +757,10 @@ describe("buildDisallowedToolsString", () => {
test("should handle custom disallowed tools when all hardcoded tools are overridden", () => { test("should handle custom disallowed tools when all hardcoded tools are overridden", () => {
const customDisallowedTools = "BadTool1,BadTool2"; const customDisallowedTools = "BadTool1,BadTool2";
const allowedTools = "WebSearch,WebFetch"; const allowedTools = "WebSearch,WebFetch";
const result = buildDisallowedToolsString(customDisallowedTools, allowedTools); const result = buildDisallowedToolsString(
customDisallowedTools,
allowedTools,
);
// Hardcoded tools should be removed // Hardcoded tools should be removed
expect(result).not.toContain("WebSearch"); expect(result).not.toContain("WebSearch");