55const AI_CREDITS_EXCEEDED_PATTERNS = [ / \b m a x [ \s _ - ] * a i [ \s _ - ] * c r e d i t s [ \s _ - ] * e x c e e d e d \b / i, / \b a i [ \s _ - ] * c r e d i t s [ \s _ - ] * r a t e [ \s _ - ] * l i m i t [ \s _ - ] * e r r o r \b / i, / a i [ \s _ - ] * c r e d i t s ? .* (?: r a t e [ \s - ] * l i m i t | l i m i t e x c e e d e d | b u d g e t e x c e e d e d | e x c e e d e d ) / i] ;
66
77const AWF_API_PROXY_BLOCKING_REQUESTS_PATTERNS = [ / \b a w f \b .* \b a p i [ \s _ - ] * p r o x y \b .* \b b l o c k i n g r e q u e s t s \b / i, / \b a p i [ \s _ - ] * p r o x y \b .* \b b l o c k i n g r e q u e s t s \b / i, / \b a p i [ \s _ - ] * p r o x y \b .* \b b l o c k e d r e q u e s t s ? \b / i, / \b D I F C _ F I L T E R E D \b / ] ;
8+ const GOAL_ALREADY_ACTIVE_PATTERNS = [ / \b c a n n o t c r e a t e a n e w g o a l b e c a u s e t h i s t h r e a d a l r e a d y h a s a g o a l \b / i, / \b t h i s t h r e a d a l r e a d y h a s a g o a l \b / i, / \b u s e u p d a t e _ g o a l o n l y w h e n t h e e x i s t i n g g o a l i s c o m p l e t e \b / i] ;
89
910/**
1011 * Detect retry guard conditions that should stop harness retries immediately.
1112 * @param {unknown } output
12- * @returns {{ aiCreditsExceeded: boolean, awfAPIProxyBlockingRequests: boolean } }
13+ * @returns {{ aiCreditsExceeded: boolean, awfAPIProxyBlockingRequests: boolean, goalAlreadyActive: boolean } }
1314 */
1415function detectNonRetryableHarnessGuard ( output ) {
1516 const safeOutput = typeof output === "string" ? output : "" ;
1617 return {
1718 aiCreditsExceeded : AI_CREDITS_EXCEEDED_PATTERNS . some ( pattern => pattern . test ( safeOutput ) ) ,
1819 awfAPIProxyBlockingRequests : AWF_API_PROXY_BLOCKING_REQUESTS_PATTERNS . some ( pattern => pattern . test ( safeOutput ) ) ,
20+ goalAlreadyActive : GOAL_ALREADY_ACTIVE_PATTERNS . some ( pattern => pattern . test ( safeOutput ) ) ,
1921 } ;
2022}
2123
@@ -24,5 +26,6 @@ if (typeof module !== "undefined" && module.exports) {
2426 detectNonRetryableHarnessGuard,
2527 AI_CREDITS_EXCEEDED_PATTERNS ,
2628 AWF_API_PROXY_BLOCKING_REQUESTS_PATTERNS ,
29+ GOAL_ALREADY_ACTIVE_PATTERNS ,
2730 } ;
2831}
0 commit comments