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 },