Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🔨 chore(userMemories): debug with more console (#11022)

Nekoc4a505508187
diff --git a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic-layers/route.ts b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic-layers/route.ts
index 00de5dfc0d5..95d7fab5ad6 100644
--- a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic-layers/route.ts
+++ b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topic-layers/route.ts
@@ -31,6 +31,8 @@ export const { POST } = serve<MemoryExtractionPayloadInput>(async (context) => {
}[] = [];
for (const topicId of params.topicIds) {
+ console.log(`[chat-topic][process-topic-layers] Processing topic ${topicId} for user ${userId} with layers:`, params.layers);
+
const extracted = await context.run(
`memory:user-memory:extract:users:${userId}:topics:${topicId}:extract-topic-other-layers`,
() =>
diff --git a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topics/workflows/workflows.ts b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topics/workflows/workflows.ts
index 94d6ac31599..76bcc0bd01f 100644
--- a/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topics/workflows/workflows.ts
+++ b/src/app/(backend)/api/workflows/memory-user-memory/pipelines/chat-topic/process-topics/workflows/workflows.ts
@@ -62,6 +62,8 @@ export const createLayerWorkflow = (allowedLayers: LayersEnum[]) =>
const results: ExtractionResult[] = [];
for (const topicId of params.topicIds) {
+ console.log(`[chat-topic][layer] ${allowedLayers} processor processing topic ${topicId} for user ${userId} with layers:`, layers);
+
const extracted = await context.run(
`memory:user-memory:extract:users:${userId}:topics:${topicId}:extract-topic-${layers.join(
'-',
@@ -79,6 +81,8 @@ export const createLayerWorkflow = (allowedLayers: LayersEnum[]) =>
}),
);
+ console.log(`[chat-topic][layer] ${allowedLayers} processor finished topic ${topicId} for user ${userId}:`, extracted);
+
results.push({ ...extracted, topicId, userId });
}
@@ -152,7 +156,15 @@ export const orchestratorWorkflow = createWorkflow<
});
while (cepIndex < topicIds.length || identityIndex < topicIds.length) {
+ console.log('[chat-topic][orchestrator] Orchestrator progress', {
+ cepIndex,
+ identityIndex,
+ totalTopics: topicIds.length,
+ });
+
if (cepIndex < topicIds.length) {
+ console.log('[chat-topic][orchestrator] Invoking CEP batch', { cepIndex });
+
const cepBatch = topicIds.slice(cepIndex, cepIndex + CEP_PARALLEL_BATCH_SIZE);
const tasks: Promise<any>[] = [invokeCep(cepBatch, cepIndex)];
@@ -162,15 +174,25 @@ export const orchestratorWorkflow = createWorkflow<
}
await Promise.all(tasks);
+ console.log('[chat-topic][orchestrator] Finished CEP batch', { cepIndex });
cepIndex += cepBatch.length;
if (shouldRunIdentity) {
identityIndex += 1;
}
} else if (identityIndex < topicIds.length) {
+ console.log('[chat-topic][orchestrator] Invoking remaining identity extraction', {
+ identityIndex,
+ topicId: topicIds[identityIndex],
+ });
+
await invokeIdentity(topicIds[identityIndex], identityIndex);
+
+ console.log('[chat-topic][orchestrator] Finished identity extraction', { identityIndex });
identityIndex += 1;
} else {
+ console.warn('[chat-topic][orchestrator] Unexpected state in orchestrator workflow');
+
break;
}
}