Skip to content

🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.

fix(evaluation): prevent setting job status to canceled for completed evaluations (#9932)

marliessophie8e9a51620cf4
diff --git a/worker/src/features/evaluation/evalService.ts b/worker/src/features/evaluation/evalService.ts
index d5afd72bbb..0ded923e8d 100644
--- a/worker/src/features/evaluation/evalService.ts
+++ b/worker/src/features/evaluation/evalService.ts
@@ -581,10 +581,14 @@ export const createEvalJobs = async ({
`Cancelling eval job for config ${config.id} and trace ${event.traceId}`,
);
- await prisma.jobExecution.update({
+ // Note: we use updateMany to gracefully handle case where execution is already completed; we silently skip the update.
+ await prisma.jobExecution.updateMany({
where: {
id: existingJob[0].id,
projectId: event.projectId,
+ status: {
+ not: JobExecutionStatus.COMPLETED,
+ },
},
data: {
status: JobExecutionStatus.CANCELLED,