mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-26 10:55:27 +00:00
fix(agent): use upsert in DatabaseSessionStorage appendEntry to handle existing entry IDs
This commit is contained in:
@@ -154,8 +154,9 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
})
|
||||
|
||||
await prisma.$transaction([
|
||||
prisma.agentSessionEntry.create({
|
||||
data: {
|
||||
prisma.agentSessionEntry.upsert({
|
||||
where: { id: entry.id },
|
||||
create: {
|
||||
id: entry.id,
|
||||
sessionId: this.sessionId,
|
||||
assetId: session?.assetId || null,
|
||||
@@ -164,6 +165,9 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
createdAt: entry.timestamp ? new Date(entry.timestamp) : new Date(),
|
||||
data: payload as PrismaJson.PiSessionEntryData,
|
||||
},
|
||||
update: {
|
||||
data: payload as PrismaJson.PiSessionEntryData,
|
||||
},
|
||||
}),
|
||||
prisma.agentSession.update({
|
||||
where: { id: this.sessionId },
|
||||
|
||||
Reference in New Issue
Block a user