🪢 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
fix: do not allow to deactivate eval configs which are only on existing objects (#5675)
Max Deichmann5d30aefcb3d2
diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.ymlindex c9fd975de6..08fa2f26f8 100644--- a/.github/workflows/pipeline.yml+++ b/.github/workflows/pipeline.yml@@ -89,7 +89,7 @@ jobs:timeout 10 bash -c 'until curl -f http://localhost:3000/api/public/health; do sleep 2; done'tests-web-sync:- timeout-minutes: 20+ timeout-minutes: 30runs-on: ubuntu-latestneeds:- pre-job@@ -165,7 +165,7 @@ jobs:run: pnpm --filter=web run test-clienttests-web-async:- timeout-minutes: 20+ timeout-minutes: 30runs-on: ubuntu-latestneeds:- pre-jobdiff --git a/web/src/__tests__/async/evals-trpc.servertest.ts b/web/src/__tests__/async/evals-trpc.servertest.tsindex 9ebbf5c1a3..39dd1985ac 100644--- a/web/src/__tests__/async/evals-trpc.servertest.ts+++ b/web/src/__tests__/async/evals-trpc.servertest.ts@@ -144,4 +144,144 @@ describe("evals trpc", () => {});});});++ describe("evals.updateConfig", () => {+ it("should update an evaluator configuration", async () => {+ const evalJobConfig = await prisma.jobConfiguration.create({+ data: {+ projectId,+ jobType: "EVAL",+ scoreName: "test-score",+ filter: [],+ targetObject: "trace",+ variableMapping: [],+ sampling: 1,+ delay: 0,+ status: "ACTIVE",+ timeScope: ["NEW"],+ },+ });++ const response = await caller.evals.updateEvalJob({+ projectId,+ evalConfigId: evalJobConfig.id,+ config: {+ status: "INACTIVE",+ },+ });++ expect(response.id).toEqual(evalJobConfig.id);+ expect(response.status).toEqual("INACTIVE");+ expect(response.timeScope).toEqual(["NEW"]);++ const updatedJob = await prisma.jobConfiguration.findUnique({+ where: {+ id: evalJobConfig.id,+ },+ });++ expect(updatedJob).not.toBeNull();+ expect(updatedJob?.id).toEqual(evalJobConfig.id);+ expect(updatedJob?.status).toEqual("INACTIVE");+ expect(updatedJob?.timeScope).toEqual(["NEW"]);+ });++ it("when the evaluator ran on existing traces, time scope cannot be changed to NEW only", async () => {+ const evalJobConfig = await prisma.jobConfiguration.create({+ data: {+ projectId,+ jobType: "EVAL",+ scoreName: "test-score",+ filter: [],+ targetObject: "trace",+ variableMapping: [],+ sampling: 1,+ delay: 0,+ status: "ACTIVE",+ timeScope: ["EXISTING"],+ },+ });++ expect(+ caller.evals.updateEvalJob({+ projectId,+ evalConfigId: evalJobConfig.id,+ config: {+ timeScope: ["NEW"],+ },+ }),+ ).rejects.toThrow(+ "The evaluator ran on existing traces already. This cannot be changed anymore.",+ );+ });++ it("when the evaluator ran on existing traces, it cannot be deactivated", async () => {+ const evalJobConfig = await prisma.jobConfiguration.create({+ data: {+ projectId,+ jobType: "EVAL",+ scoreName: "test-score",+ filter: [],+ targetObject: "trace",+ variableMapping: [],+ sampling: 1,+ delay: 0,+ status: "ACTIVE",+ timeScope: ["EXISTING"],+ },+ });++ expect(+ caller.evals.updateEvalJob({+ projectId,+ evalConfigId: evalJobConfig.id,+ config: {+ status: "INACTIVE",+ },+ }),+ ).rejects.toThrow(+ "The evaluator is running on existing traces only and cannot be deactivated.",+ );+ });++ it("when the evaluator ran on existing traces, it can be deactivated if it should also run on new traces", async () => {+ const evalJobConfig = await prisma.jobConfiguration.create({+ data: {+ projectId,+ jobType: "EVAL",+ scoreName: "test-score",+ filter: [],+ targetObject: "trace",+ variableMapping: [],+ sampling: 1,+ delay: 0,+ status: "ACTIVE",+ timeScope: ["EXISTING", "NEW"],+ },+ });++ const response = await caller.evals.updateEvalJob({+ projectId,+ evalConfigId: evalJobConfig.id,+ config: {+ status: "INACTIVE",+ },+ });++ expect(response.id).toEqual(evalJobConfig.id);+ expect(response.status).toEqual("INACTIVE");+ expect(response.timeScope).toEqual(["EXISTING", "NEW"]);++ const updatedJob = await prisma.jobConfiguration.findUnique({+ where: {+ id: evalJobConfig.id,+ },+ });++ expect(updatedJob).not.toBeNull();+ expect(updatedJob?.id).toEqual(evalJobConfig.id);+ expect(updatedJob?.status).toEqual("INACTIVE");+ expect(updatedJob?.timeScope).toEqual(["EXISTING", "NEW"]);+ });+ });});diff --git a/web/src/ee/features/evals/components/evaluator-detail.tsx b/web/src/ee/features/evals/components/evaluator-detail.tsxindex 2e7df24310..606939d162 100644--- a/web/src/ee/features/evals/components/evaluator-detail.tsx+++ b/web/src/ee/features/evals/components/evaluator-detail.tsx@@ -223,7 +223,11 @@ export function DeactivateEvaluator({<PopoverTrigger asChild><div className="flex items-center"><Switch- disabled={!hasAccess}+ disabled={+ !hasAccess ||+ (evaluator?.timeScope?.length === 1 &&+ evaluator.timeScope[0] === "EXISTING")+ }checked={isActive}className={isActive ? "data-[state=checked]:bg-dark-green" : ""}/>diff --git a/web/src/ee/features/evals/server/router.ts b/web/src/ee/features/evals/server/router.tsindex 743578b8dd..358221c419 100644--- a/web/src/ee/features/evals/server/router.ts+++ b/web/src/ee/features/evals/server/router.ts@@ -724,13 +724,48 @@ export const evalRouter = createTRPCRouter({},});+ if (!existingJob) {+ logger.warn(+ `Job for update not found for project ${projectId} and id ${evalConfigId}`,+ );+ throw new TRPCError({+ code: "NOT_FOUND",+ message: "Job not found",+ });+ }+if (- existingJob?.timeScope.includes("EXISTING") &&- !config.timeScope?.includes("EXISTING")+ // check if:+ // - existing job ran on existing traces+ // - user wants to update the time scope+ // - new time scope does not include EXISTING+ existingJob.timeScope.includes("EXISTING") &&+ config.timeScope &&+ !config.timeScope.includes("EXISTING")) {- throw new Error(- "The evaluator ran on existing traces already. This cannot be changed anymore.",+ logger.error(+ `Job ${evalConfigId} for project ${projectId} ran on existing traces already. This cannot be changed anymore`,);+ throw new TRPCError({+ code: "BAD_REQUEST",+ message:+ "The evaluator ran on existing traces already. This cannot be changed anymore.",+ });+ }++ if (+ existingJob.timeScope.includes("EXISTING") &&+ !existingJob.timeScope.includes("NEW") &&+ config.status === "INACTIVE"+ ) {+ logger.error(+ `Job ${evalConfigId} for project ${projectId} is running on existing traces only and cannot be deactivated`,+ );+ throw new TRPCError({+ code: "BAD_REQUEST",+ message:+ "The evaluator is running on existing traces only and cannot be deactivated.",+ });}await auditLog({@@ -740,7 +775,7 @@ export const evalRouter = createTRPCRouter({action: "update",});- await ctx.prisma.jobConfiguration.update({+ const updatedJob = await ctx.prisma.jobConfiguration.update({where: {id: evalConfigId,projectId: projectId,@@ -780,6 +815,8 @@ export const evalRouter = createTRPCRouter({{ delay: config.delay },);}++ return updatedJob;}),getLogs: protectedProjectProcedure