Skip to content

Commit 4c466c9

Browse files
committed
perf(shared): keep only short labels in the tool-name cache
The tool-name cache bounded its entry count but not key size. ACP tool titles can carry whole commands, so up to 10,000 long strings could stay in the module-level map until the next clear. Labels over 256 characters are now parsed without being cached; real T3 MCP tool names are far shorter, so the rows the cache was for still hit it.
1 parent a32a754 commit 4c466c9

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

‎packages/shared/src/t3McpToolPresentation.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,10 +381,13 @@ function normalizeT3McpToolLabel(value: string): string {
381381
}
382382

383383
// Timelines resolve every work row's tool name on each update; names repeat across updates.
384+
// ACP titles can carry whole commands, so long labels are parsed but not kept.
384385
const toolNameCache = new Map<string, string | null>();
385386
const TOOL_NAME_CACHE_LIMIT = 10_000;
387+
const TOOL_NAME_CACHE_MAX_KEY_LENGTH = 256;
386388

387389
function resolveT3McpToolName(value: string): string | null {
390+
if (value.length > TOOL_NAME_CACHE_MAX_KEY_LENGTH) return parseT3McpToolName(value);
388391
const cached = toolNameCache.get(value);
389392
if (cached !== undefined) return cached;
390393
const name = parseT3McpToolName(value);

0 commit comments

Comments
 (0)