fix: align tool rename fallout
This commit is contained in:
@@ -313,12 +313,12 @@ describe("context-pruning", () => {
|
||||
makeUser("u1"),
|
||||
makeToolResult({
|
||||
toolCallId: "t1",
|
||||
toolName: "bash",
|
||||
toolName: "Bash",
|
||||
text: "x".repeat(20_000),
|
||||
}),
|
||||
makeToolResult({
|
||||
toolCallId: "t2",
|
||||
toolName: "browser",
|
||||
toolName: "Browser",
|
||||
text: "y".repeat(20_000),
|
||||
}),
|
||||
];
|
||||
|
||||
@@ -2,7 +2,13 @@ import type { ContextPruningToolMatch } from "./settings.js";
|
||||
|
||||
function normalizePatterns(patterns?: string[]): string[] {
|
||||
if (!Array.isArray(patterns)) return [];
|
||||
return patterns.map((p) => String(p ?? "").trim()).filter(Boolean);
|
||||
return patterns
|
||||
.map((p) =>
|
||||
String(p ?? "")
|
||||
.trim()
|
||||
.toLowerCase(),
|
||||
)
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
type CompiledPattern =
|
||||
@@ -39,8 +45,9 @@ export function makeToolPrunablePredicate(
|
||||
const allow = compilePatterns(match.allow);
|
||||
|
||||
return (toolName: string) => {
|
||||
if (matchesAny(toolName, deny)) return false;
|
||||
const normalized = toolName.trim().toLowerCase();
|
||||
if (matchesAny(normalized, deny)) return false;
|
||||
if (allow.length === 0) return true;
|
||||
return matchesAny(toolName, allow);
|
||||
return matchesAny(normalized, allow);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user