From 74a9de290e331c386df62918e815d20e40b69899 Mon Sep 17 00:00:00 2001 From: Ajax Davis Date: Tue, 13 Jan 2026 11:31:13 +1000 Subject: [PATCH] fix: support agent UID lookup in conversation endpoint --- .../conversation/[conversationId]/route.ts | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/apps/web/src/app/api/agents/[id]/conversation/[conversationId]/route.ts b/apps/web/src/app/api/agents/[id]/conversation/[conversationId]/route.ts index f40ffba..33b5ba7 100644 --- a/apps/web/src/app/api/agents/[id]/conversation/[conversationId]/route.ts +++ b/apps/web/src/app/api/agents/[id]/conversation/[conversationId]/route.ts @@ -114,9 +114,11 @@ export async function POST(request: NextRequest, context: RouteContext): Promise ); } - // Fetch agent with all tool relations using agent ID - const { fetchAgentWithTools, buildAgentTools } = await import('@/lib/agents/build-tools'); - const agent = await fetchAgentWithTools(agentId); + // Fetch agent with all tool relations using agent ID or UID + const { fetchAgentByIdOrUidWithTools, buildAgentTools } = await import( + '@/lib/agents/build-tools' + ); + const agent = await fetchAgentByIdOrUidWithTools(agentId); if (!agent) { return NextResponse.json({ success: false, error: 'Agent not found' }, { status: 404 }); @@ -569,9 +571,11 @@ export async function GET(request: NextRequest, context: RouteContext): Promise< const after = searchParams.get('after'); try { - // Fetch agent by ID with more details for JSON format - const agent = await prisma.agent.findUnique({ - where: { id: agentId }, + // Fetch agent by ID or UID with more details for JSON format + const agent = await prisma.agent.findFirst({ + where: { + OR: [{ id: agentId }, { uid: agentId }], + }, select: { id: true, uid: true, @@ -744,9 +748,11 @@ export async function DELETE(_request: NextRequest, context: RouteContext): Prom const { id: agentId, conversationId } = await context.params; try { - // Fetch agent by ID - const agent = await prisma.agent.findUnique({ - where: { id: agentId }, + // Fetch agent by ID or UID + const agent = await prisma.agent.findFirst({ + where: { + OR: [{ id: agentId }, { uid: agentId }], + }, select: { id: true }, });