@peopl-health/nexus 5.48.0-dev.7402 → 5.48.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -612,14 +612,17 @@ class BaseLLMProvider {
|
|
|
612
612
|
} catch (error) {
|
|
613
613
|
// Keyed on the signal, not the error type: an AbortError from some unrelated inner timeout is not a supersede.
|
|
614
614
|
const aborted = Boolean(config.signal?.aborted);
|
|
615
|
-
logger.error('[runConversation] Attempt failed', { attempt, error: error.message });
|
|
616
615
|
if (aborted || isSuperseded(config.shouldContinue)) {
|
|
617
|
-
logger.info('[runConversation] Superseded — abandoning after error', { attempt, shadow: config.shadow, aborted });
|
|
616
|
+
logger.info('[runConversation] Superseded — abandoning after error', { attempt, shadow: config.shadow, aborted, error: error.message });
|
|
618
617
|
const ctx = config?.assistant?.toolRuntimeContext;
|
|
619
618
|
if (aborted && ctx) ctx.abort = { reason: 'superseded', iteration: ctx.trace ? (ctx.trace.iterations?.length ?? 0) + 1 : null };
|
|
620
619
|
return { status: 'cancelled', output_text: '', tools_executed: [], retries: 0 };
|
|
621
620
|
}
|
|
622
|
-
if (attempt === maxRetries)
|
|
621
|
+
if (attempt === maxRetries) {
|
|
622
|
+
logger.error('[runConversation] Attempt failed', { attempt, error: error.message });
|
|
623
|
+
throw error;
|
|
624
|
+
}
|
|
625
|
+
logger.warn('[runConversation] Attempt failed, retrying', { attempt, maxRetries, error: error.message });
|
|
623
626
|
await new Promise(r => setTimeout(r, 500));
|
|
624
627
|
}
|
|
625
628
|
}
|
|
@@ -678,7 +678,7 @@ class NexusMessaging {
|
|
|
678
678
|
|
|
679
679
|
if (storeRunMetrics) await storeRunMetrics(chatId, resolved.thread, result, preProcessed.timings);
|
|
680
680
|
return { ...result, timings: preProcessed.timings };
|
|
681
|
-
}, shouldContinue);
|
|
681
|
+
}, shouldContinue, runId);
|
|
682
682
|
}
|
|
683
683
|
);
|
|
684
684
|
}
|
|
@@ -988,15 +988,16 @@ class NexusMessaging {
|
|
|
988
988
|
);
|
|
989
989
|
}
|
|
990
990
|
|
|
991
|
-
async _processMessages(chatId, processingFn, shouldFinalize = () => true) {
|
|
991
|
+
async _processMessages(chatId, processingFn, shouldFinalize = () => true, runId = null) {
|
|
992
992
|
const query = { numero: chatId, from_me: false, processed: false };
|
|
993
993
|
const unprocessed = await getMessages(query, { select: '_id' });
|
|
994
994
|
|
|
995
995
|
try {
|
|
996
996
|
const result = await processingFn();
|
|
997
997
|
if (unprocessed.length > 0 && shouldFinalize()) {
|
|
998
|
-
|
|
999
|
-
|
|
998
|
+
const marks = runId ? { processed: true, processedByTurnId: runId } : { processed: true };
|
|
999
|
+
await Message.updateMany({ _id: { $in: unprocessed.map(m => m._id) } }, { $set: marks });
|
|
1000
|
+
logger.info('[_processMessages] Marked messages as processed', { count: unprocessed.length, chatId, runId });
|
|
1000
1001
|
}
|
|
1001
1002
|
return result;
|
|
1002
1003
|
} catch (error) {
|
|
@@ -84,6 +84,7 @@ const messageSchema = new mongoose.Schema({
|
|
|
84
84
|
preset: { type: Object, default: null },
|
|
85
85
|
response_id: { type: String, default: null },
|
|
86
86
|
turnId: { type: String },
|
|
87
|
+
processedByTurnId: { type: String },
|
|
87
88
|
traceId: { type: String },
|
|
88
89
|
triggeredBy: { type: String, default: null }
|
|
89
90
|
}, { timestamps: true });
|