From b9ba5778f5df6b4a1c204a2885440766881c20a4 Mon Sep 17 00:00:00 2001 From: Ruslan Bakiev <572431+veikab@users.noreply.github.com> Date: Fri, 20 Feb 2026 16:26:34 +0700 Subject: [PATCH] require contactId for contact summary updates --- frontend/server/agent/langgraphCrmAgent.ts | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/server/agent/langgraphCrmAgent.ts b/frontend/server/agent/langgraphCrmAgent.ts index 0d75d1f..5f36735 100644 --- a/frontend/server/agent/langgraphCrmAgent.ts +++ b/frontend/server/agent/langgraphCrmAgent.ts @@ -795,13 +795,16 @@ export async function runLangGraphCrmAgentFor(input: { } if (raw.action === "updateContactSummary") { - const contactName = (raw.contact ?? "").trim(); + const contactId = (raw.contactId ?? "").trim(); const content = (raw.summary ?? raw.content ?? "").trim(); - if (!contactName) throw new Error("contact is required"); + if (!contactId) throw new Error("contactId is required"); if (!content) throw new Error("summary is required"); - const contact = await resolveContact(input.teamId, contactName); - if (!contact) throw new Error("contact not found"); + const contact = await prisma.contact.findFirst({ + where: { id: contactId, teamId: input.teamId }, + select: { id: true, name: true }, + }); + if (!contact) throw new Error("contactId not found"); await prisma.contactNote.upsert({ where: { contactId: contact.id }, update: { content },