fix: align tool rename fallout

This commit is contained in:
Peter Steinberger
2026-01-09 05:54:34 +01:00
parent 333832c2e1
commit aa5e75e853
8 changed files with 42 additions and 34 deletions

View File

@@ -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),
}),
];

View File

@@ -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);
};
}