feat(core): enhance loop detection with 2-stage check (#12902)

This commit is contained in:
Sandy Tao
2025-11-11 20:49:00 -08:00
committed by GitHub
parent cab9b1f370
commit 408b885689
10 changed files with 438 additions and 60 deletions
+16
View File
@@ -48,6 +48,7 @@ import type {
RecoveryAttemptEvent,
WebFetchFallbackAttemptEvent,
ExtensionUpdateEvent,
LlmLoopCheckEvent,
} from './types.js';
import {
recordApiErrorMetrics,
@@ -654,3 +655,18 @@ export function logWebFetchFallbackAttempt(
};
logger.emit(logRecord);
}
export function logLlmLoopCheck(
config: Config,
event: LlmLoopCheckEvent,
): void {
ClearcutLogger.getInstance(config)?.logLlmLoopCheckEvent(event);
if (!isTelemetrySdkInitialized()) return;
const logger = logs.getLogger(SERVICE_NAME);
const logRecord: LogRecord = {
body: event.toLogBody(),
attributes: event.toOpenTelemetryAttributes(config),
};
logger.emit(logRecord);
}