perf(background-agent): use Set for countedToolPartIDs, cache circuit breaker settings, optimize loop detector
- Replace countedToolPartIDs string[] with Set<string> for O(1) has/add vs O(n) includes/spread (C2) - Cache resolveCircuitBreakerSettings at manager level to avoid repeated object creation (C3) - Optimize recordToolCall to avoid full array copy with slice (L1)
This commit is contained in:
@@ -44,7 +44,9 @@ export function recordToolCall(
|
||||
): ToolCallWindow {
|
||||
const previous = window?.toolSignatures ?? []
|
||||
const signature = createToolCallSignature(toolName, toolInput)
|
||||
const toolSignatures = [...previous, signature].slice(-settings.windowSize)
|
||||
const toolSignatures = previous.length >= settings.windowSize
|
||||
? [...previous.slice(1), signature]
|
||||
: [...previous, signature]
|
||||
|
||||
return {
|
||||
toolSignatures,
|
||||
|
||||
Reference in New Issue
Block a user