Feat: auto-cleanup duplicate agents on label edit

This commit is contained in:
ypratama committed 2026-09-07 11:26:41 +07:00
1 parent 6a23577b08
commit f7ebd7a5c5
1 file changed
+6
+6
View File
@@ -34,6 +34,12 @@ export async function updateAgent(agentId: string, label: string) {
{ _id: agent._id },
{ $set: { label: label } }
);
// Bismillah: Hapus semua data duplikat/hantu milik agent ini agar tidak ditimpa oleh proxy lawas/bug ganda
await db.collection('agent_registry').deleteMany({
$or: [{ uuid: agentId }, { serial: agentId }],
_id: { $ne: agent._id }
});
// Also try to update the summaries if possible, so historical displays match
await db.collection('summaries').updateMany(