MCPcopy Create free account
hub / github.com/beita6969/ScienceClaw / resolveLoopDetectionConfig

Function resolveLoopDetectionConfig

src/agents/tool-loop-detection.ts:64–100  ·  view source on GitHub ↗
(config?: ToolLoopDetectionConfig)

Source from the content-addressed store, hash-verified

62}
63
64function resolveLoopDetectionConfig(config?: ToolLoopDetectionConfig): ResolvedLoopDetectionConfig {
65 let warningThreshold = asPositiveInt(
66 config?.warningThreshold,
67 DEFAULT_LOOP_DETECTION_CONFIG.warningThreshold,
68 );
69 let criticalThreshold = asPositiveInt(
70 config?.criticalThreshold,
71 DEFAULT_LOOP_DETECTION_CONFIG.criticalThreshold,
72 );
73 let globalCircuitBreakerThreshold = asPositiveInt(
74 config?.globalCircuitBreakerThreshold,
75 DEFAULT_LOOP_DETECTION_CONFIG.globalCircuitBreakerThreshold,
76 );
77
78 if (criticalThreshold <= warningThreshold) {
79 criticalThreshold = warningThreshold + 1;
80 }
81 if (globalCircuitBreakerThreshold <= criticalThreshold) {
82 globalCircuitBreakerThreshold = criticalThreshold + 1;
83 }
84
85 return {
86 enabled: config?.enabled ?? DEFAULT_LOOP_DETECTION_CONFIG.enabled,
87 historySize: asPositiveInt(config?.historySize, DEFAULT_LOOP_DETECTION_CONFIG.historySize),
88 warningThreshold,
89 criticalThreshold,
90 globalCircuitBreakerThreshold,
91 detectors: {
92 genericRepeat:
93 config?.detectors?.genericRepeat ?? DEFAULT_LOOP_DETECTION_CONFIG.detectors.genericRepeat,
94 knownPollNoProgress:
95 config?.detectors?.knownPollNoProgress ??
96 DEFAULT_LOOP_DETECTION_CONFIG.detectors.knownPollNoProgress,
97 pingPong: config?.detectors?.pingPong ?? DEFAULT_LOOP_DETECTION_CONFIG.detectors.pingPong,
98 },
99 };
100}
101
102/**
103 * Hash a tool call for pattern matching.

Callers 3

detectToolCallLoopFunction · 0.85
recordToolCallFunction · 0.85
recordToolCallOutcomeFunction · 0.85

Calls 1

asPositiveIntFunction · 0.85

Tested by

no test coverage detected