fix(core): update loop detection LLM schema fields (#12091)

This commit is contained in:
Sandy Tao
2025-10-27 12:16:25 -07:00
committed by GitHub
parent 29efebe38f
commit 4ef3c09332
2 changed files with 29 additions and 20 deletions

View File

@@ -413,18 +413,21 @@ export class LoopDetectionService {
const schema: Record<string, unknown> = {
type: 'object',
properties: {
reasoning: {
unproductive_state_analysis: {
type: 'string',
description:
'Your reasoning on if the conversation is looping without forward progress.',
},
confidence: {
unproductive_state_confidence: {
type: 'number',
description:
'A number between 0.0 and 1.0 representing your confidence that the conversation is in an unproductive state.',
},
},
required: ['reasoning', 'confidence'],
required: [
'unproductive_state_analysis',
'unproductive_state_confidence',
],
};
let result;
try {
@@ -442,10 +445,13 @@ export class LoopDetectionService {
return false;
}
if (typeof result['confidence'] === 'number') {
if (result['confidence'] > 0.9) {
if (typeof result['reasoning'] === 'string' && result['reasoning']) {
debugLogger.warn(result['reasoning']);
if (typeof result['unproductive_state_confidence'] === 'number') {
if (result['unproductive_state_confidence'] > 0.9) {
if (
typeof result['unproductive_state_analysis'] === 'string' &&
result['unproductive_state_analysis']
) {
debugLogger.warn(result['unproductive_state_analysis']);
}
logLoopDetected(
this.config,
@@ -456,7 +462,7 @@ export class LoopDetectionService {
this.llmCheckInterval = Math.round(
MIN_LLM_CHECK_INTERVAL +
(MAX_LLM_CHECK_INTERVAL - MIN_LLM_CHECK_INTERVAL) *
(1 - result['confidence']),
(1 - result['unproductive_state_confidence']),
);
}
}