🪢 Open source agent evals & observability: Trace, evaluate, and improve LLM applications with one open platform.
TypeScript analyticsautogenevaluationlangchainlarge-language-modelsllama-indexllmllm-evaluationllm-observabilityllmopsmonitoringobservabilityopen-sourceopenaiplaygroundprompt-engineeringprompt-managementself-hostedycombinator
chore: gracefully handle failed evals (#7500)
Max Deichmannf1ca851b0d74
diff --git a/worker/src/features/evaluation/evalService.ts b/worker/src/features/evaluation/evalService.tsindex 82bf6c7694..47e3555b03 100644--- a/worker/src/features/evaluation/evalService.ts+++ b/worker/src/features/evaluation/evalService.ts@@ -596,7 +596,7 @@ export const evaluate = async ({);if (!modelConfig.valid) {- logger.error(+ logger.warn(`Evaluating job ${event.jobExecutionId} will fail. ${modelConfig.error}`,);throw new LangfuseNotFoundError(modelConfig.error);@@ -737,7 +737,7 @@ export async function extractVariablesFromTracingData({}if (mapping.langfuseObject === "dataset_item") {if (!datasetItemId) {- logger.error(+ logger.warn(`No dataset item id found for variable ${variable}. Eval will succeed without dataset item input.`,);return { var: variable, value: "" };@@ -770,10 +770,11 @@ export async function extractVariablesFromTracingData({// user facing errorsif (!datasetItem) {logger.error(- `Dataset item ${datasetItemId} for project ${projectId} not found. Eval will succeed without dataset item input. Please ensure the mapped data on the dataset item exists and consider extending the job delay.`,+ `Dataset item ${datasetItemId} for project ${projectId} not found. Please ensure the mapped data on the dataset item exists and consider extending the job delay.`,);+ // this should only happen for deleted data.throw new LangfuseNotFoundError(- `Dataset item ${datasetItemId} for project ${projectId} not found. Eval will succeed without dataset item input. Please ensure the mapped data on the dataset item exists and consider extending the job delay.`,+ `Dataset item ${datasetItemId} for project ${projectId} not found. Please ensure the mapped data on the dataset item exists and consider extending the job delay.`,);}@@ -801,11 +802,12 @@ export async function extractVariablesFromTracingData({// user facing errorsif (!trace) {- logger.error(- `Trace ${traceId} for project ${projectId} not found. Eval will succeed without trace input. Please ensure the mapped data on the trace exists and consider extending the job delay.`,+ logger.warn(+ `Trace ${traceId} for project ${projectId} not found. Please ensure the mapped data on the trace exists and consider extending the job delay.`,);+ // this should only happen for deleted data or replication lags across clickhouse nodes.throw new LangfuseNotFoundError(- `Trace ${traceId} for project ${projectId} not found. Eval will succeed without trace input. Please ensure the mapped data on the trace exists and consider extending the job delay.`,+ `Trace ${traceId} for project ${projectId} not found. Please ensure the mapped data on the trace exists and consider extending the job delay.`,);}@@ -847,9 +849,10 @@ export async function extractVariablesFromTracingData({// user facing errorsif (!observation) {- logger.error(+ logger.warn(`Observation ${mapping.objectName} for trace ${traceId} not found. Please ensure the mapped data exists and consider extending the job delay.`,);+ // this should only happen for deleted data or data replication lags across clickhouse nodes.throw new LangfuseNotFoundError(`Observation ${mapping.objectName} for trace ${traceId} not found. Please ensure the mapped data exists and consider extending the job delay.`,);diff --git a/worker/src/queues/evalQueue.ts b/worker/src/queues/evalQueue.tsindex bea77abed5..8dec3c0a8b 100644--- a/worker/src/queues/evalQueue.ts+++ b/worker/src/queues/evalQueue.ts@@ -1,5 +1,5 @@import { Job } from "bullmq";-import { ApiError, BaseError } from "@langfuse/shared";+import { ApiError, BaseError, LangfuseNotFoundError } from "@langfuse/shared";import { kyselyPrisma } from "@langfuse/shared/src/db";import { sql } from "kysely";import {@@ -83,7 +83,10 @@ export const evalJobExecutorQueueProcessor = async (return true;} catch (e) {// If the job fails with a 429, we want to retry it unless it's older than 24h.- if (e instanceof ApiError && e.httpCode === 429) {+ if (+ (e instanceof ApiError && e.httpCode === 429) || // retry all rate limits+ (e instanceof ApiError && e.httpCode >= 500) // retry all 5xx errors+ ) {try {// Check if the job execution is older than 24hconst jobExecution = await kyselyPrisma.$kysely@@ -128,6 +131,8 @@ export const evalJobExecutorQueueProcessor = async (}}+ // we are left with 4xx and application errors here.+const displayError =e instanceof BaseError ? e.message : "An internal error occurred";@@ -142,6 +147,7 @@ export const evalJobExecutorQueueProcessor = async (// do not log expected errors (api failures + missing api keys not provided by the user)if (+ e instanceof LangfuseNotFoundError ||(e instanceof BaseError &&e.message.includes("Could not parse response content as the length limit was reached",