Skip to content

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

feat(v4-upgrade): improve eval-upgrade flow (#15470)

marliessophie2463bece3e53
diff --git a/web/src/__tests__/server/unit/v4TransitionRouter.servertest.ts b/web/src/__tests__/server/unit/v4TransitionRouter.servertest.ts
index 6b059b7adc..08d2238f22 100644
--- a/web/src/__tests__/server/unit/v4TransitionRouter.servertest.ts
+++ b/web/src/__tests__/server/unit/v4TransitionRouter.servertest.ts
@@ -643,21 +643,83 @@ describe("v4TransitionRouter", () => {
it("summarizes trace-level evals", async () => {
const mockPrisma = {
jobConfiguration: {
- count: vi.fn().mockResolvedValue(3),
+ findMany: vi.fn().mockResolvedValue([
+ { targetObject: "dataset", variableMapping: [] },
+ {
+ targetObject: "trace",
+ variableMapping: [
+ {
+ templateVariable: "input",
+ langfuseObject: "generation",
+ objectName: "my-generation",
+ selectedColumnId: "input",
+ },
+ ],
+ },
+ {
+ targetObject: "trace",
+ variableMapping: [
+ {
+ templateVariable: "input",
+ langfuseObject: "trace",
+ selectedColumnId: "input",
+ },
+ ],
+ },
+ ]),
},
};
const caller = createCaller(mockPrisma);
+ // The third config maps from the trace itself, so the set is not fully
+ // assistant-migratable.
await expect(caller.traceLevelEvalSummary({ projectId })).resolves.toEqual({
traceLevelEvalCount: 3,
+ allAssistantMigratable: false,
});
- expect(mockPrisma.jobConfiguration.count).toHaveBeenCalledWith({
+ expect(mockPrisma.jobConfiguration.findMany).toHaveBeenCalledWith({
where: {
projectId,
jobType: "EVAL",
- targetObject: "trace",
+ targetObject: { in: ["trace", "dataset"] },
+ status: "ACTIVE",
+ timeScope: { has: "NEW" },
+ },
+ select: { targetObject: true, variableMapping: true },
+ });
+ });
+
+ it("marks evals as assistant-migratable when all are dataset targets or single-observation mappings", async () => {
+ const mockPrisma = {
+ jobConfiguration: {
+ findMany: vi.fn().mockResolvedValue([
+ { targetObject: "dataset", variableMapping: [] },
+ {
+ targetObject: "trace",
+ variableMapping: [
+ {
+ templateVariable: "input",
+ langfuseObject: "generation",
+ objectName: "my-generation",
+ selectedColumnId: "input",
+ },
+ {
+ templateVariable: "output",
+ langfuseObject: "generation",
+ objectName: "my-generation",
+ selectedColumnId: "output",
+ },
+ ],
+ },
+ ]),
},
+ };
+ const caller = createCaller(mockPrisma);
+
+ await expect(caller.traceLevelEvalSummary({ projectId })).resolves.toEqual({
+ traceLevelEvalCount: 2,
+ allAssistantMigratable: true,
});
});
@@ -824,7 +886,9 @@ describe("v4TransitionRouter", () => {
where: {
projectId: { in: [projectId, secondProjectId] },
jobType: "EVAL",
- targetObject: "trace",
+ targetObject: { in: ["trace", "dataset"] },
+ status: "ACTIVE",
+ timeScope: { has: "NEW" },
},
_count: { _all: true },
});
@@ -1021,7 +1085,9 @@ describe("v4TransitionRouter", () => {
expect(queryText).toContain("je.project_id = ?");
expect(queryText).toContain("jc.project_id = ?");
expect(queryText).toContain("jc.job_type = 'EVAL'");
- expect(queryText).toContain("jc.target_object = ?");
+ expect(queryText).toContain("jc.target_object IN (?, ?)");
+ expect(queryText).toContain("jc.status = 'ACTIVE'");
+ expect(queryText).toContain("'NEW' = ANY(jc.time_scope)");
expect(queryText).toContain("je.status != 'CANCELLED'");
expect(queryText).toContain("je.created_at >= ?");
expect(queryText).toContain("je.created_at <= ?");
@@ -1032,6 +1098,7 @@ describe("v4TransitionRouter", () => {
projectId,
projectId,
"trace",
+ "dataset",
new Date("2026-06-25T12:00:00Z"),
new Date("2026-06-25T13:00:00Z"),
]);
diff --git a/web/src/components/table/peek/peek-evaluator-config-detail.tsx b/web/src/components/table/peek/peek-evaluator-config-detail.tsx
index efb38bc561..ff4260bdb2 100644
--- a/web/src/components/table/peek/peek-evaluator-config-detail.tsx
+++ b/web/src/components/table/peek/peek-evaluator-config-detail.tsx
@@ -9,8 +9,10 @@ import {
TooltipContent,
TooltipTrigger,
} from "@/src/components/ui/tooltip";
+import { V4MigrationUpdateRequiredAssistantBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";
import { UserCircle2Icon } from "lucide-react";
import { StatusBadge } from "@/src/components/layouts/status-badge";
+import { DeleteEvalConfigButton } from "@/src/components/deleteButton";
import { DeactivateEvalConfig } from "@/src/features/evals/components/deactivate-config";
import { Switch } from "@/src/components/design-system/Switch/Switch";
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
@@ -18,12 +20,15 @@ import { useState } from "react";
import { cn } from "@/src/utils/tailwind";
import { showSuccessToast } from "@/src/features/notifications/showSuccessToast";
import { api } from "@/src/utils/api";
-import { LegacyEvalCallout } from "@/src/features/evals/components/legacy-eval-callout";
import { EvaluatorPausedCallout } from "@/src/features/evals/components/evaluator-paused-callout";
-import { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";
+import {
+ isLegacyEvalTarget,
+ requiresLegacyMigrationAction,
+} from "@/src/features/evals/utils/typeHelpers";
import { useLazyEvaluatorExecutionCounts } from "@/src/features/evals/hooks/useLazyEvaluatorExecutionCounts";
import { TablePeekView } from "@/src/components/table/peek";
import { LangfuseIcon } from "@/src/components/design-system/LangfuseIcon/LangfuseIcon";
+import { useEvalCapabilities } from "@/src/features/evals/hooks/useEvalCapabilities";
const PeekViewEvaluatorConfigDetail = ({
projectId,
@@ -34,7 +39,7 @@ const PeekViewEvaluatorConfigDetail = ({
const peekId = router.query.peek as string | undefined;
const [isEditMode, setIsEditMode] = useState(false);
const utils = api.useUtils();
-
+ const { allowLegacy } = useEvalCapabilities(projectId);
const { data: evalConfig } = usePeekEvalConfigData({
jobConfigurationId: peekId,
projectId,
@@ -54,6 +59,12 @@ const PeekViewEvaluatorConfigDetail = ({
const displayStatus =
lazyExecutionCounts.displayStatus ?? evalConfig.displayStatus;
+ const evaluatorRequiresMigration = requiresLegacyMigrationAction({
+ targetObject: evalConfig.targetObject,
+ status: evalConfig.status,
+ timeScope: Array.isArray(evalConfig.timeScope) ? evalConfig.timeScope : [],
+ });
+
return (
<div className="grid h-full flex-1 grid-rows-[auto_auto_1fr] gap-2 overflow-hidden p-3 contain-layout">
<div className="flex items-center justify-between">
@@ -65,7 +76,10 @@ const PeekViewEvaluatorConfigDetail = ({
isLive
className="max-h-8"
/>
- {isLegacyEvalTarget(evalConfig.targetObject) && (
+ {/* Quick-deactivate is a migration aid: only shown where legacy
+ evals can no longer be set up (cloud), consistent with the
+ read-only edit gate. */}
+ {isLegacyEvalTarget(evalConfig.targetObject) && !allowLegacy && (
<DeactivateEvalConfig
projectId={projectId}
evalConfig={evalConfig}
@@ -74,6 +88,11 @@ const PeekViewEvaluatorConfigDetail = ({
</div>
</div>
<div className="flex items-center gap-2">
+ {evaluatorRequiresMigration && (
+ <span className="bg-light-yellow text-dark-yellow inline-flex w-fit shrink-0 items-center rounded-full px-2 py-0.5 text-xs font-bold whitespace-nowrap">
+ Deprecated
+ </span>
+ )}
<span
className={cn("text-sm", isEditMode ? "" : "text-muted-foreground")}
>
@@ -81,27 +100,35 @@ const PeekViewEvaluatorConfigDetail = ({
</span>
<Switch
disabled={
- !hasAccess ||
- (isLegacyEvalTarget(evalConfig.targetObject) &&
- evalConfig?.timeScope?.length === 1 &&
- evalConfig.timeScope[0] === "EXISTING")
+ !hasAccess || (evaluatorRequiresMigration && !allowLegacy)
}
checked={isEditMode}
onCheckedChange={setIsEditMode}
+ {...(evaluatorRequiresMigration &&
+ !allowLegacy && {
+ title:
+ "Deprecated evaluators are only available in read-only mode",
+ })}
+ />
+ <DeleteEvalConfigButton
+ aria-label="delete"
+ itemId={evalConfig.id}
+ projectId={projectId}
+ deleteConfirmation={evalConfig.scoreName}
+ // The peek only exists on the evals list page; redirecting there
+ // drops the peek query params and closes it after deletion.
+ redirectUrl={`/project/${projectId}/evals`}
+ icon
+ variant="ghost"
+ size="icon-xs"
+ title="Delete"
/>
</div>
</div>
- {evalConfig &&
- evalConfig.targetObject &&
- evalConfig.evalTemplate &&
- displayStatus === "ACTIVE" && (
- <LegacyEvalCallout
- projectId={projectId}
- evalConfigId={evalConfig.id}
- targetObject={evalConfig.targetObject}
- />
- )}
+ {evaluatorRequiresMigration && evalConfig.evalTemplate && (
+ <V4MigrationUpdateRequiredAssistantBadge />
+ )}
<EvaluatorPausedCallout projectId={projectId} evalConfig={evalConfig} />
diff --git a/web/src/features/evals/components/deactivate-config.tsx b/web/src/features/evals/components/deactivate-config.tsx
index 435b9d00bf..b509aaaa81 100644
--- a/web/src/features/evals/components/deactivate-config.tsx
+++ b/web/src/features/evals/components/deactivate-config.tsx
@@ -10,6 +10,8 @@ import {
} from "@/src/components/ui/popover";
import { Button } from "@/src/components/ui/button";
import { Switch } from "@/src/components/design-system/Switch/Switch";
+import { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";
+import { useEvalCapabilities } from "@/src/features/evals/hooks/useEvalCapabilities";
export function DeactivateEvalConfig({
projectId,
@@ -20,9 +22,17 @@ export function DeactivateEvalConfig({
}) {
const utils = api.useUtils();
const hasAccess = useHasProjectAccess({ projectId, scope: "evalJob:CUD" });
+ const { allowLegacy } = useEvalCapabilities(projectId);
const [isOpen, setIsOpen] = useState(false);
const capture = usePostHogClientCapture();
const isActive = evalConfig?.status === EvaluatorStatus.ACTIVE;
+ // Where new legacy setups are not allowed (cloud), deactivating a legacy
+ // evaluator is a one-way door: reactivating it would amount to setting up
+ // a legacy eval again.
+ const reactivationBlocked =
+ !isActive &&
+ isLegacyEvalTarget(evalConfig?.targetObject ?? "") &&
+ !allowLegacy;
const mutEvaluator = api.evals.updateEvalJob.useMutation({
onSuccess: () => {
@@ -35,6 +45,11 @@ export function DeactivateEvalConfig({
console.error("Project ID is missing");
return;
}
+ // The popover trigger wraps the switch, so guard the action itself too.
+ if (reactivationBlocked) {
+ setIsOpen(false);
+ return;
+ }
const prevStatus = evalConfig?.status;
@@ -60,11 +75,16 @@ export function DeactivateEvalConfig({
<Switch
disabled={
!hasAccess ||
+ reactivationBlocked ||
(evalConfig?.timeScope?.length === 1 &&
evalConfig.timeScope[0] === "EXISTING")
}
checked={isActive}
color="green"
+ {...(reactivationBlocked && {
+ title:
+ "Deprecated evaluators cannot be reactivated. Migrate to the new evaluators instead.",
+ })}
/>
</div>
</PopoverTrigger>
diff --git a/web/src/features/evals/components/evaluator-table.tsx b/web/src/features/evals/components/evaluator-table.tsx
index f54d6982bc..9b09ff91cf 100644
--- a/web/src/features/evals/components/evaluator-table.tsx
+++ b/web/src/features/evals/components/evaluator-table.tsx
@@ -18,13 +18,11 @@ import { createColumnHelper } from "@tanstack/react-table";
import { useEffect, useState, useMemo } from "react";
import { useQueryParam, StringParam, withDefault } from "use-query-params";
import { usePaginationState } from "@/src/hooks/usePaginationState";
-import {
- isLegacyEvalTarget,
- isEventTarget,
-} from "@/src/features/evals/utils/typeHelpers";
+import { isEventTarget } from "@/src/features/evals/utils/typeHelpers";
+import { useEvalCapabilities } from "@/src/features/evals/hooks/useEvalCapabilities";
import { useOrderByState } from "@/src/features/orderBy/hooks/useOrderByState";
import TableIdOrName from "@/src/components/table/table-id";
-import { ExternalLinkIcon, Info, Pen } from "lucide-react";
+import { ExternalLinkIcon, Pen } from "lucide-react";
import { usePeekNavigation } from "@/src/components/table/peek/hooks/usePeekNavigation";
import { TablePeekViewEvaluatorConfigDetail } from "@/src/components/table/peek/peek-evaluator-config-detail";
import { evalConfigTargetValues } from "@/src/server/api/definitions/evalConfigsTable";
@@ -44,14 +42,6 @@ import { MaintainerTooltip } from "@/src/features/evals/components/maintainer-to
import { useHasProjectAccess } from "@/src/features/rbac/utils/checkProjectAccess";
import { Skeleton } from "@/src/components/ui/skeleton";
import { usdFormatter } from "@/src/utils/numbers";
-import { Callout } from "@/src/components/ui/callout";
-import Link from "next/link";
-import { Badge } from "@/src/components/ui/badge";
-import {
- Tooltip,
- TooltipContent,
- TooltipTrigger,
-} from "@/src/components/ui/tooltip";
import {
type EvaluatorDataRow,
useEvaluatorTableData,
@@ -63,42 +53,12 @@ import {
TableTextLoadingCell,
} from "@/src/components/table/loading-cells";
-function LegacyBadgeCell({ status }: { status: string }) {
+function DeprecatedChipCell() {
return (
<div className="flex items-center gap-1.5">
- <Badge variant="warning">
- Legacy
- {status === "ACTIVE" && (
- <Tooltip>
- <TooltipTrigger>
- <Info className="text-dark-yellow ml-1 h-3.5 w-3.5" />
- </TooltipTrigger>
- <TooltipContent className="max-w-[280px]">
- <div className="space-y-1 text-sm">
- <p className="font-bold">Action required</p>
- <p className="text-muted-foreground">
- This evaluator requires changes to benefit from new features
- and performance improvements. Please follow{" "}
- <Link
- href="https://langfuse.com/faq/all/llm-as-a-judge-migration"
- target="_blank"
- rel="noopener noreferrer"
- className="text-dark-blue font-bold hover:opacity-80"
- onClick={(e) => {
- e.stopPropagation();
- }}
- >
- this guide
- </Link>{" "}
- to upgrade to the new version. <br /> <br /> If you do not
- upgrade, your evaluator will continue to run, but you will not
- benefit from improvements.
- </p>
- </div>
- </TooltipContent>
- </Tooltip>
- )}
- </Badge>
+ <span className="bg-light-yellow text-dark-yellow inline-flex w-fit shrink-0 items-center rounded-full px-2 py-0.5 text-xs font-bold whitespace-nowrap">
+ Deprecated
+ </span>
</div>
);
}
@@ -137,15 +97,14 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
},
);
- const { evaluators, rows, totalCount, hasLegacyEvals } =
- useEvaluatorTableData({
- projectId,
- page: paginationState.pageIndex,
- limit: paginationState.pageSize,
- filter: queryFilter.filterState,
- orderBy: orderByState,
- searchQuery,
- });
+ const { evaluators, rows, totalCount } = useEvaluatorTableData({
+ projectId,
+ page: paginationState.pageIndex,
+ limit: paginationState.pageSize,
+ filter: queryFilter.filterState,
+ orderBy: orderByState,
+ searchQuery,
+ });
const existingEvaluator = api.evals.configById.useQuery(
{
@@ -158,6 +117,9 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
);
const hasAccess = useHasProjectAccess({ projectId, scope: "evalJob:CUD" });
+ // Deprecated evaluators are read-only where new legacy setups are not
+ // allowed (cloud); self-hosted deployments keep editing them.
+ const { allowLegacy } = useEvalCapabilities(projectId);
const datasets = api.datasets.allDatasetMeta.useQuery({ projectId });
@@ -295,13 +257,11 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
enableHiding: true,
loadingCell: <TableBadgeLoadingCell />,
cell: (row) => {
- const targetObject = row.row.original.target;
- const status = row.row.original.rawStatus;
- const isDeprecated = isLegacyEvalTarget(targetObject);
+ // Set by useEvaluatorTableData only for active legacy evaluators with
+ // a NEW time scope — the ones that actually require migration.
+ if (!row.row.original.isLegacy) return null;
- if (!isDeprecated) return null;
-
- return <LegacyBadgeCell status={status} />;
+ return <DeprecatedChipCell />;
},
}),
columnHelper.accessor("target", {
@@ -372,9 +332,11 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
label="Edit"
aria-label="edit"
disabledReason={
- hasAccess
- ? undefined
- : "You don't have permission to edit this evaluator."
+ !hasAccess
+ ? "You don't have permission to edit this evaluator."
+ : row.original.isLegacy && !allowLegacy
+ ? "Deprecated evaluators are only available in read-only mode."
+ : undefined
}
onClick={(e) => {
e.stopPropagation();
@@ -426,41 +388,6 @@ export default function EvaluatorTable({ projectId }: { projectId: string }) {
defaultSidebarCollapsed={evaluatorFilterConfig.defaultSidebarCollapsed}
>
<div className="flex h-full w-full flex-col">
- {hasLegacyEvals && (
- <div className="p-2 pb-0">
- <Callout
- id="eval-remapping-table"
- variant="warning"
- key="dismissed-eval-remapping-callouts"
- >
- <span>New functionality has landed. </span>
- <span className="font-bold">
- Some of your evaluators (marked &quot;Legacy&quot;) require
- changes{" "}
- </span>
- <span>to benefit from new features and improvements. </span>
- <Link
- href="https://langfuse.com/faq/all/llm-as-a-judge-migration"
- target="_blank"
- rel="noopener noreferrer"
- className="text-dark-blue font-bold hover:opacity-80"
- >
- Learn what is changing and how to upgrade
- </Link>
- <span>.</span>
- <Tooltip>
- <TooltipTrigger asChild>
- <Info className="ml-1 inline h-4 w-4 cursor-help" />
- </TooltipTrigger>
- <TooltipContent>
- Your evaluator will continue to work without upgrading, but
- you will not benefit from performance improvements.
- </TooltipContent>
- </Tooltip>
- </Callout>
- </div>
- )}
-
{/* Toolbar spanning full width */}
<DataTableToolbar
columns={columns}
diff --git a/web/src/features/evals/components/inner-evaluator-form.tsx b/web/src/features/evals/components/inner-evaluator-form.tsx
index 45308fd252..ce44ecd236 100644
--- a/web/src/features/evals/components/inner-evaluator-form.tsx
+++ b/web/src/features/evals/components/inner-evaluator-form.tsx
@@ -342,6 +342,13 @@ export const InnerEvaluatorForm = (props: {
// Destructure eval capabilities passed from parent
const { allowLegacy } = props.evalCapabilities;
+ // Existing legacy evaluators must keep rendering their (read-only) legacy
+ // target UI in edit mode even when new legacy setups are not allowed.
+ const showLegacyTargetOptions =
+ allowLegacy ||
+ (props.mode === "edit" &&
+ isLegacyEvalTarget(props.existingEvaluator?.targetObject ?? ""));
+
// Custom hooks for managing evaluator state
const {
userFacingTarget,
@@ -852,7 +859,7 @@ export const InnerEvaluatorForm = (props: {
<CircleDot className="h-3.5 w-3.5" />
Observations
</TabsTrigger>
- {allowLegacy && (
+ {showLegacyTargetOptions && (
<TabsTrigger
value="trace"
disabled={props.disabled || props.mode === "edit"}
@@ -889,7 +896,7 @@ export const InnerEvaluatorForm = (props: {
{/* Second tab bar for experiment data source selection */}
{!props.hideTargetSelection &&
userFacingTarget === "offline-experiment" &&
- props.evalCapabilities.allowLegacy && (
+ showLegacyTargetOptions && (
<div className="flex flex-col gap-2">
<FormLabel className="text-sm">Experiment Method</FormLabel>
<Tabs
diff --git a/web/src/features/evals/components/legacy-eval-callout.tsx b/web/src/features/evals/components/legacy-eval-callout.tsx
deleted file mode 100644
index 18509c2a4d..0000000000
--- a/web/src/features/evals/components/legacy-eval-callout.tsx
+++ /dev/null
@@ -1,73 +0,0 @@
-import { Callout } from "@/src/components/ui/callout";
-import { Button } from "@/src/components/ui/button";
-import {
- Tooltip,
- TooltipTrigger,
- TooltipContent,
-} from "@/src/components/ui/tooltip";
-import Link from "next/link";
-import { useRouter } from "next/router";
-import { Info } from "lucide-react";
-import { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";
-
-interface LegacyEvalCalloutProps {
- projectId: string;
- evalConfigId: string;
- targetObject: string;
-}
-
-export function LegacyEvalCallout({
- projectId,
- evalConfigId,
- targetObject,
-}: LegacyEvalCalloutProps) {
- const router = useRouter();
- const isDeprecated = isLegacyEvalTarget(targetObject);
-
- if (!isDeprecated) return null;
-
- return (
- <Callout
- id={`eval-remapping-peek-${evalConfigId}`}
- variant="warning"
- key="dismissed-eval-remapping-callouts"
- actions={() => (
- <>
- <Button
- variant="ghost"
- size="sm"
- onClick={() =>
- router.push(
- `/project/${projectId}/evals/remap?evaluator=${evalConfigId}`,
- )
- }
- className="text-dark-blue h-7 text-xs hover:opacity-80"
- >
- Upgrade this evaluator
- </Button>
- </>
- )}
- >
- <span>This evaluator </span>
- <span className="text-dark-blue hover:opacity-80">
- <Link
- href="https://langfuse.com/faq/all/llm-as-a-judge-migration"
- target="_blank"
- rel="noopener noreferrer"
- >
- requires changes{" "}
- </Link>
- </span>
- <span>to benefit from new features and performance improvements.</span>
- <Tooltip>
- <TooltipTrigger asChild>
- <Info className="ml-1 inline h-4 w-4 cursor-help" />
- </TooltipTrigger>
- <TooltipContent>
- Your evaluator will continue to work without upgrading, but you will
- not benefit from improvements.
- </TooltipContent>
- </Tooltip>
- </Callout>
- );
-}
diff --git a/web/src/features/evals/hooks/useEvalCapabilities.ts b/web/src/features/evals/hooks/useEvalCapabilities.ts
index 16800a0e32..3945a051d8 100644
--- a/web/src/features/evals/hooks/useEvalCapabilities.ts
+++ b/web/src/features/evals/hooks/useEvalCapabilities.ts
@@ -51,13 +51,11 @@ export function useEvalCapabilities(
const { isLangfuseCloud } = useLangfuseCloudRegion();
const v4WriteMode = session?.environment?.v4WriteMode;
- // Whether a *new* config may use the legacy experience (independent of
- // hasLegacyEvals, which always keeps legacy visible so existing legacy
- // evaluators stay manageable):
+ // Whether a *new* config may use the legacy experience:
// - events_only: legacy tables are no longer written → no new legacy evals.
- // - dual: self-hosted deployments always allow legacy; on Cloud, new legacy
- // evals are only available via hasLegacyEvals (projects that already have
- // legacy evaluators) — being able to toggle V4 is not enough.
+ // - dual: self-hosted deployments always allow legacy; on Cloud, no new
+ // legacy evals — existing legacy evaluators stay visible in read-only mode,
+ // but cannot be newly set up.
// - legacy: legacy is the only experience.
const modeAllowsNewLegacy =
v4WriteMode === "events_only"
@@ -70,9 +68,10 @@ export function useEvalCapabilities(
isNewCompatible: isOtel,
// True when v4 beta is enabled (SDK check query was run)
compatibilityCheckWasPerformed: isBetaEnabled,
- // Allow legacy if: not a code eval AND (user has legacy evals to manage OR
- // the deployment mode/cohort offers the legacy experience).
- allowLegacy: !isCodeEvalConfig && (hasLegacyEvals || modeAllowsNewLegacy),
+ // Allow setting up new legacy evals only if: not a code eval AND the
+ // deployment mode offers the legacy experience. Having existing legacy
+ // evals no longer grants this; they remain editable via edit mode.
+ allowLegacy: !isCodeEvalConfig && modeAllowsNewLegacy,
isLoading:
evalCounts.isLoading || isSessionLoading || sdkVersionInfo.isLoading,
hasLegacyEvals,
diff --git a/web/src/features/evals/hooks/useEvaluatorTableData.ts b/web/src/features/evals/hooks/useEvaluatorTableData.ts
index 901c1d701f..8a9ab6a623 100644
--- a/web/src/features/evals/hooks/useEvaluatorTableData.ts
+++ b/web/src/features/evals/hooks/useEvaluatorTableData.ts
@@ -12,7 +12,7 @@ import {
useLazyEvaluatorExecutionCountsByIds,
} from "@/src/features/evals/hooks/useLazyEvaluatorExecutionCounts";
import { generateJobExecutionCounts } from "@/src/features/evals/utils/job-execution-utils";
-import { isLegacyEvalTarget } from "@/src/features/evals/utils/typeHelpers";
+import { requiresLegacyMigrationAction } from "@/src/features/evals/utils/typeHelpers";
import { RAGAS_TEMPLATE_PREFIX } from "@/src/features/evals/types";
export type EvaluatorDataRow = {
@@ -136,7 +136,11 @@ export const useEvaluatorTableData = ({
: "Langfuse maintained"
: "Not available",
totalCost: costData,
- isLegacy: isLegacyEvalTarget(jobConfig.targetObject),
+ isLegacy: requiresLegacyMigrationAction({
+ targetObject: jobConfig.targetObject,
+ status: jobConfig.status,
+ timeScope: jobConfig.timeScope,
+ }),
} satisfies EvaluatorDataRow;
}),
[
@@ -151,8 +155,7 @@ export const useEvaluatorTableData = ({
evaluators,
rows,
totalCount: evaluators.data?.totalCount ?? null,
- hasLegacyEvals: rows.some(
- (row) => row.status === "ACTIVE" && Boolean(row.isLegacy),
- ),
+ // isLegacy already requires ACTIVE status and a NEW time scope
+ hasLegacyEvals: rows.some((row) => Boolean(row.isLegacy)),
};
};
diff --git a/web/src/features/evals/pages/evaluators.tsx b/web/src/features/evals/pages/evaluators.tsx
index 6228548b85..0307756250 100644
--- a/web/src/features/evals/pages/evaluators.tsx
+++ b/web/src/features/evals/pages/evaluators.tsx
@@ -14,6 +14,7 @@ import { SupportOrUpgradePage } from "@/src/ee/features/billing/components/Suppo
import { EvaluatorsOnboarding } from "@/src/components/onboarding/EvaluatorsOnboarding";
import { ManageDefaultEvalModel } from "@/src/features/evals/components/manage-default-eval-model";
import { V4MigrationModal } from "@/src/features/v4-migration/V4MigrationModal";
+import { V4MigrationUpdateRequiredBadge } from "@/src/features/v4-migration/V4MigrationDelayBadge";
export default function EvaluatorsPage() {
const router = useRouter();
@@ -79,6 +80,7 @@ export default function EvaluatorsPage() {
<Page
headerProps={{
title: "Evaluators",
+ titleBadges: <V4MigrationUpdateRequiredBadge />,
help: {
description:
"Configure a langfuse managed or custom evaluator to evaluate incoming traces.",
diff --git a/web/src/features/evals/utils/typeHelpers.ts b/web/src/features/evals/utils/typeHelpers.ts
index 42686da16b..2608987b69 100644
--- a/web/src/features/evals/utils/typeHelpers.ts
+++ b/web/src/features/evals/utils/typeHelpers.ts
@@ -35,6 +35,21 @@ export const isLegacyEvalTarget = (targetObject: string): boolean => {
);
};
+/**
+ * True when the legacy-migration nag (deprecated badge, callout, migration
+ * dialog count) should show: the evaluator targets a legacy object AND is
+ * actively evaluating new data. Inactive or backfill-only (EXISTING) legacy
+ * evaluators keep working and need no action, so they get no label.
+ */
+export const requiresLegacyMigrationAction = (evaluator: {
+ targetObject: string;
+ status: string;
+ timeScope: string[];
+}): boolean =>
+ isLegacyEvalTarget(evaluator.targetObject) &&
+ evaluator.status === "ACTIVE" &&
+ evaluator.timeScope.includes("NEW");
+
export const isTraceTarget = (targetObject: string): boolean => {
return targetObject === EvalTargetObject.TRACE;
};
diff --git a/web/src/features/posthog-analytics/usePostHogClientCapture.ts b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
index b9b1ccd5ef..dab8445420 100644
--- a/web/src/features/posthog-analytics/usePostHogClientCapture.ts
+++ b/web/src/features/posthog-analytics/usePostHogClientCapture.ts
@@ -312,6 +312,8 @@ export const events = {
"contact_book_call_clicked",
"contact_support_clicked",
"status_row_clicked",
+ "update_required_badge_clicked",
+ "migrate_evals_with_agent_clicked",
],
// Filter/search-bar usage analytics (LFE-10781). METADATA ONLY — payloads
// never carry a raw filter value, search text, or AI prompt (PII). Only
diff --git a/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx b/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx
index 21cbf97049..bc7af07389 100644
--- a/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx
+++ b/web/src/features/v4-migration/V4MigrationContent.clienttest.tsx
@@ -36,8 +36,27 @@ vi.mock("@/src/features/projects/hooks", () => ({
vi.mock("@/src/features/v4-migration/hooks/useV4MigrationData", () => ({
useProjectV4MigrationData: () => mocks.migrationData,
+ useProjectV4SdkData: () => mocks.migrationData.sdk,
+ useProjectV4EvalData: () => mocks.migrationData.evals,
}));
+// The plan hook queries tRPC internally; mock it so tests need no provider.
+vi.mock("@/src/features/v4-migration/useV4UpgradeAssistantSupport", () => ({
+ useEvalUpgradeAssistantPlan: () => ({
+ canUseAssistant: false,
+ assistantCanUpgrade: false,
+ assistantPrompt: "",
+ }),
+}));
+
+vi.mock(
+ "@/src/ee/features/in-app-agent/components/InAppAiAgentProvider",
+ () => ({
+ useCanUseInAppAgent: () => false,
+ useInAppAiAgent: () => ({ setOpen: vi.fn(), submit: vi.fn() }),
+ }),
+);
+
vi.mock("@/src/components/ui/collapsible", () => ({
Collapsible: ({ children }: { children: React.ReactNode }) => (
<div>{children}</div>
@@ -116,5 +135,8 @@ describe("V4MigrationDetailsContent", () => {
expect(
screen.getByText("No deprecated integration exports detected."),
).toBeInTheDocument();
+ expect(
+ screen.getByText("No deprecated evals detected."),
+ ).toBeInTheDocument();
});
});
diff --git a/web/src/features/v4-migration/V4MigrationContent.tsx b/web/src/features/v4-migration/V4MigrationContent.tsx
index a95e7ccd0d..e8a1fa0e83 100644
--- a/web/src/features/v4-migration/V4MigrationContent.tsx
+++ b/web/src/features/v4-migration/V4MigrationContent.tsx
@@ -2,12 +2,14 @@ import { type ReactNode } from "react";
import { useRouter } from "next/router";
import Link from "next/link";
import {
+ BotMessageSquare,
ChevronRight,
Copy,
LibraryBig,
LifeBuoy,
TriangleAlert,
} from "lucide-react";
+import { useInAppAiAgent } from "@/src/ee/features/in-app-agent/components/InAppAiAgentProvider";
import { useSupportDrawer } from "@/src/features/support-chat/SupportDrawerProvider";
import { Button } from "@/src/components/ui/button";
import { RainbowButton } from "@/src/components/magicui/rainbow-button";
@@ -33,6 +35,7 @@ import {
import { numberFormatter } from "@/src/utils/numbers";
import { formatCompactRelativeTime } from "@/src/utils/dates";
import { useProject } from "@/src/features/projects/hooks";
+import { useEvalUpgradeAssistantPlan } from "@/src/features/v4-migration/useV4UpgradeAssistantSupport";
// Single source of truth for the v4-migration copy and content. Both surfaces
// (side panel and modal) render these components — edit copy here only.
@@ -344,6 +347,21 @@ export function V4MigrationDetailsContent({
onNavigate?.();
openSupportDrawerWithMode("form", { topic: "V4 Migration" });
};
+ const { setOpen: setAgentOpen, submit: submitAgentMessage } =
+ useInAppAiAgent();
+ const upgradePlan = useEvalUpgradeAssistantPlan({
+ projectId,
+ orgId: organization?.id,
+ enabled: Boolean(projectId),
+ });
+ const handleMigrateEvalsWithAgent = async () => {
+ capture("v4_migration:migrate_evals_with_agent_clicked");
+ onNavigate?.();
+ setAgentOpen(true);
+ await submitAgentMessage(upgradePlan.assistantPrompt, {
+ newConversation: true,
+ });
+ };
const evalsUrl =
typeof projectId === "string" ? `/project/${projectId}/evals` : undefined;
const integrationsUrl =
@@ -383,8 +401,8 @@ export function V4MigrationDetailsContent({
update?
</div>
<p className="text-muted-foreground text-sm">
- Some features will stop working after{" "}
- <span className="text-dark-yellow">Oct 1</span>.
+ Some features will stop working{" "}
+ <span className="text-dark-yellow">soon</span>.
</p>
<div>
<V4MigrationSdkSection sdk={migrationData.sdk} />
@@ -413,24 +431,43 @@ export function V4MigrationDetailsContent({
{migrationData.evals.count === 1
? "eval targets"
: "evals target"}{" "}
- trace input/output, which stops running{" "}
- <span className="text-dark-yellow">Oct 1</span>. Point{" "}
- {migrationData.evals.count === 1 ? "it" : "them"} at an
- observation instead.
+ trace input/output, which{" "}
+ <span className="text-dark-yellow">
+ {migrationData.evals.count === 1 ? "stops" : "stop"} running
+ soon
+ </span>
+ . Repointing {migrationData.evals.count === 1 ? "it" : "them"}{" "}
+ at observations or experiments requires minimal changes
+ {upgradePlan.assistantCanUpgrade
+ ? " — the assistant can do it for you"
+ : ""}
+ .
</p>
- {evalsUrl ? (
- <Link
- href={evalsUrl}
- onClick={onNavigate}
- className="text-dark-blue text-sm hover:underline"
- >
- Review trace-level evals
- </Link>
- ) : null}
+ <div className="flex items-center gap-3">
+ {upgradePlan.assistantCanUpgrade && (
+ <Button
+ variant="outline"
+ size="sm"
+ onClick={handleMigrateEvalsWithAgent}
+ >
+ <BotMessageSquare className="mr-1.5 h-4 w-4" />
+ Migrate with assistant
+ </Button>
+ )}
+ {evalsUrl ? (
+ <Link
+ href={evalsUrl}
+ onClick={onNavigate}
+ className="text-dark-blue text-sm hover:underline"
+ >
+ Review deprecated evals
+ </Link>
+ ) : null}
+ </div>
</>
) : (
<p className="text-muted-foreground text-sm">
- No configured trace-level evals detected.
+ No deprecated evals detected.
</p>
)}
</Section>
@@ -457,7 +494,7 @@ export function V4MigrationDetailsContent({
<p className="text-muted-foreground mb-2 text-sm">
You&apos;ve called these deprecated endpoints in the last{" "}
{V4_MIGRATION_LOOKBACK_DAYS} days. They stop working{" "}
- <span className="text-dark-yellow">Oct 1</span>; the{" "}
+ <span className="text-dark-yellow">soon</span>; the{" "}
<ExternalLink href={DEPRECATED_API_MIGRATION_URL}>
migration guide
</ExternalLink>{" "}
diff --git a/web/src/features/v4-migration/V4MigrationDelayBadge.tsx b/web/src/features/v4-migration/V4MigrationDelayBadge.tsx
index 3fa5a6b475..7fd861d9f0 100644
--- a/web/src/features/v4-migration/V4MigrationDelayBadge.tsx
+++ b/web/src/features/v4-migration/V4MigrationDelayBadge.tsx
@@ -3,7 +3,45 @@ import { useV4UpgradeUiEnabled } from "@/src/features/v4-migration/useV4UpgradeU
import { usePostHogClientCapture } from "@/src/features/posthog-analytics/usePostHogClientCapture";
import { useQueryProject } from "@/src/features/projects/hooks";
import { useOpenV4MigrationPanel } from "@/src/features/v4-migration/hooks/useOpenV4MigrationPanel";
-import { useProjectV4SdkData } from "@/src/features/v4-migration/hooks/useV4MigrationData";
+import {
+ useProjectV4EvalData,
+ useProjectV4SdkData,
+} from "@/src/features/v4-migration/hooks/useV4MigrationData";
+import {
+ useCanUseInAppAgent,
+ useInAppAiAgent,
+} from "@/src/ee/features/in-app-agent/components/InAppAiAgentProvider";
+import { useEvalUpgradeAssistantPlan } from "@/src/features/v4-migration/useV4UpgradeAssistantSupport";
+
+function BadgeContent({
+ handleClick,
+ title,
+ description,
+}: {
+ handleClick: () => void;
+ title: string;
+ description: string;
+}) {
+ return (
+ <button
+ type="button"
+ onClick={handleClick}
+ className="group ring-input hover:bg-muted/50 hover:text-foreground inline-flex w-fit flex-none shrink-0 items-center gap-1.5 rounded-full bg-transparent px-2 py-0.5 text-xs font-bold whitespace-nowrap ring"
+ >
+ <span
+ aria-hidden
+ className="size-1.75 shrink-0 rounded-full bg-orange-400 dark:bg-orange-400"
+ ></span>
+ <span className="flex items-center">
+ {title}
+ <span className="flex max-w-0 items-center overflow-hidden transition-[max-width] duration-300 ease-out group-hover:max-w-96">
+ <span className="whitespace-nowrap">.&nbsp;{description}.</span>
+ </span>
+ <ChevronRight className="ml-1 h-3 w-3 shrink-0" />
+ </span>
+ </button>
+ );
+}
export function V4MigrationDelayBadge() {
const v4UpgradeUiEnabled = useV4UpgradeUiEnabled();
@@ -26,24 +64,99 @@ export function V4MigrationDelayBadge() {
};
return (
- <button
- type="button"
- onClick={handleClick}
- className="group ring-input hover:bg-muted/50 hover:text-foreground inline-flex w-fit flex-none shrink-0 items-center gap-1.5 rounded-full bg-transparent px-2 py-0.5 text-xs font-bold whitespace-nowrap ring"
- >
- <span
- aria-hidden
- className="size-1.75 shrink-0 rounded-full bg-orange-400 dark:bg-orange-400"
- ></span>
- <span className="flex items-center">
- New data in ~15 min
- <span className="flex max-w-0 items-center overflow-hidden transition-[max-width] duration-300 ease-out group-hover:max-w-96">
- <span className="whitespace-nowrap">
- .&nbsp;Update your SDK for real-time data.
- </span>
- </span>
- <ChevronRight className="ml-1 h-3 w-3 shrink-0" />
- </span>
- </button>
+ <BadgeContent
+ handleClick={handleClick}
+ title="New data in ~15 min"
+ description="Update your SDK for real-time data"
+ />
+ );
+}
+
+/** Shared gating for the eval "Action required" badges: v4 upgrade UI flag,
+ * project context, and a loaded, non-zero deprecated-eval count. */
+function useEvalUpdateRequiredBadgeState() {
+ const v4UpgradeUiEnabled = useV4UpgradeUiEnabled();
+ const { project, organization } = useQueryProject();
+ const enabled = v4UpgradeUiEnabled && Boolean(project);
+ const evalState = useProjectV4EvalData({
+ projectId: project?.id,
+ orgId: organization?.id,
+ enabled,
+ });
+
+ const visible =
+ v4UpgradeUiEnabled &&
+ Boolean(project) &&
+ evalState.status === "loaded" &&
+ evalState.count > 0;
+
+ return { project, organization, enabled, visible };
+}
+
+/** Opens the v4 migration drawer — for page-level surfaces where the drawer
+ * is fully visible (e.g. the evaluators page header). */
+export function V4MigrationUpdateRequiredBadge() {
+ const openMigrationPanel = useOpenV4MigrationPanel();
+ const capture = usePostHogClientCapture();
+ const { project, visible } = useEvalUpdateRequiredBadgeState();
+
+ if (!visible || !project) {
+ return null;
+ }
+
+ const handleClick = () => {
+ capture("v4_migration:update_required_badge_clicked");
+ openMigrationPanel({ id: project.id, name: project.name });
+ };
+
+ return (
+ <BadgeContent
+ handleClick={handleClick}
+ title="Action required"
+ description="Update your eval set up"
+ />
+ );
+}
+
+/** Starts the eval upgrade in the in-app assistant — for overlay surfaces
+ * like the table peek, where the assistant (`agent` layer) renders above the
+ * peek (`panel` layer) while the migration drawer would open behind it.
+ * Falls back to the drawer when the assistant is unavailable. */
+export function V4MigrationUpdateRequiredAssistantBadge() {
+ const openMigrationPanel = useOpenV4MigrationPanel();
+ const capture = usePostHogClientCapture();
+ const canUseAgent = useCanUseInAppAgent();
+ const { setOpen: setAgentOpen, submit: submitAgentMessage } =
+ useInAppAiAgent();
+ const { project, organization, enabled, visible } =
+ useEvalUpdateRequiredBadgeState();
+ const upgradePlan = useEvalUpgradeAssistantPlan({
+ projectId: project?.id,
+ orgId: organization?.id,
+ enabled,
+ });
+
+ if (!visible || !project) {
+ return null;
+ }
+
+ const handleClick = async () => {
+ capture("v4_migration:update_required_badge_clicked");
+ if (canUseAgent) {
+ setAgentOpen(true);
+ await submitAgentMessage(upgradePlan.assistantPrompt, {
+ newConversation: true,
+ });
+ return;
+ }
+ openMigrationPanel({ id: project.id, name: project.name });
+ };
+
+ return (
+ <BadgeContent
+ handleClick={handleClick}
+ title="Action required"
+ description="Click here to start the upgrade now"
+ />
);
}
diff --git a/web/src/features/v4-migration/V4MigrationStatusPage.tsx b/web/src/features/v4-migration/V4MigrationStatusPage.tsx
index eac7e5b81e..52cdc35c64 100644
--- a/web/src/features/v4-migration/V4MigrationStatusPage.tsx
+++ b/web/src/features/v4-migration/V4MigrationStatusPage.tsx
@@ -452,9 +452,9 @@ function V4MigrationStatusPageContent() {
<>
Yes, eventually. The{" "}
<FaqLink href={SDK_UPGRADE_URL}>old SDKs</FaqLink>, trace-level evals,
- and APIs are frozen and stop working on{" "}
- <span className="underline">Oct 1</span>. They keep running until
- then, but we&apos;re no longer fixing bugs in them.
+ and APIs are frozen and stop working{" "}
+ <span className="underline">soon</span>. They keep running until then,
+ but we&apos;re no longer fixing bugs in them.
</>
),
},
@@ -479,8 +479,8 @@ function V4MigrationStatusPageContent() {
q: "What if I do nothing?",
a: (
<>
- On <span className="underline">Oct 1</span>, old SDKs stop sending
- data, and the{" "}
+ <span className="underline">Soon</span>, old SDKs stop sending data,
+ and the{" "}
<FaqLink href={API_REFERENCE_URL}>
deprecated evals and endpoints
</FaqLink>{" "}
diff --git a/web/src/features/v4-migration/hooks/useV4MigrationData.ts b/web/src/features/v4-migration/hooks/useV4MigrationData.ts
index 3f21bd8fa7..e2e7ce5369 100644
--- a/web/src/features/v4-migration/hooks/useV4MigrationData.ts
+++ b/web/src/features/v4-migration/hooks/useV4MigrationData.ts
@@ -155,6 +155,20 @@ export function useProjectV4SdkData(params: {
});
}
+export function useProjectV4EvalData(params: {
+ projectId: string | undefined;
+ orgId: string | undefined;
+ enabled: boolean;
+}) {
+ const { projectId, enabled } = params;
+ const queryEnabled = enabled && Boolean(projectId);
+ const evalQuery = api.v4Transition.traceLevelEvalSummary.useQuery(
+ { projectId: projectId ?? "" },
+ { ...queryOptions, enabled: queryEnabled },
+ );
+ return getMigrationCountState(evalQuery, (data) => data.traceLevelEvalCount);
+}
+
export function useProjectV4MigrationData(params: {
projectId: string | undefined;
orgId: string | undefined;
diff --git a/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts
new file mode 100644
index 0000000000..e8eacfe895
--- /dev/null
+++ b/web/src/features/v4-migration/useV4UpgradeAssistantSupport.ts
@@ -0,0 +1,51 @@
+import { useCanUseInAppAgent } from "@/src/ee/features/in-app-agent/components/InAppAiAgentProvider";
+import { useProjectV4SdkData } from "@/src/features/v4-migration/hooks/useV4MigrationData";
+import { api } from "@/src/utils/api";
+
+const EVAL_UPGRADE_ASSISTANT_PROMPT =
+ "I want to start my eval upgrade. Use the langfuse skill. Please review this project's deprecated evaluators (trace- and dataset-level), that are both ACTIVE and run on NEW time scope, and help me migrate them to the new targets — observations and experiments. Check with me before applying any changes.";
+
+const UPGRADE_OUTSIDE_PLATFORM_PROMPT =
+ "I want to upgrade my Langfuse setup to v4, but parts of it must be upgraded outside of Langfuse, which you cannot do from here. Please tell me to copy the upgrade prompt from the 'Copy prompt for agents' button in the v4 migration panel and run it in my coding editor (Cursor, Codex, Claude Code).";
+
+/**
+ * Whether the in-app assistant can complete the remaining v4 upgrade.
+ * True only when ALL of:
+ * - deprecated evals remain AND the SDK upgrade is already done, and
+ * - every remaining legacy eval is trivially repointable (dataset target, or
+ * a variable mapping that reads from a single observation) — computed
+ * server-side as `allAssistantMigratable`.
+ *
+ * `assistantPrompt` is what the "upgrade now" entry points submit to the
+ * assistant: the eval-upgrade instruction when it can do the work, otherwise
+ * an instruction to point the user at the coding-agent prompt.
+ */
+export function useEvalUpgradeAssistantPlan(params: {
+ projectId: string | undefined;
+ orgId: string | undefined;
+ enabled: boolean;
+}) {
+ const canUseAssistant = useCanUseInAppAgent();
+ const sdk = useProjectV4SdkData(params);
+ const evalQuery = api.v4Transition.traceLevelEvalSummary.useQuery(
+ { projectId: params.projectId ?? "" },
+ { enabled: params.enabled && Boolean(params.projectId) },
+ );
+
+ const sdkUpgradeDone =
+ sdk.status === "latest" || sdk.status === "otel_realtime";
+ const evalsPending = (evalQuery.data?.traceLevelEvalCount ?? 0) > 0;
+ const assistantCanUpgrade =
+ canUseAssistant &&
+ sdkUpgradeDone &&
+ evalsPending &&
+ evalQuery.data?.allAssistantMigratable === true;
+
+ return {
+ canUseAssistant,
+ assistantCanUpgrade,
+ assistantPrompt: assistantCanUpgrade
+ ? EVAL_UPGRADE_ASSISTANT_PROMPT
+ : UPGRADE_OUTSIDE_PLATFORM_PROMPT,
+ };
+}
diff --git a/web/src/features/v4/server/v4TransitionRouter.ts b/web/src/features/v4/server/v4TransitionRouter.ts
index 75b725e5e1..1a07e03d9a 100644
--- a/web/src/features/v4/server/v4TransitionRouter.ts
+++ b/web/src/features/v4/server/v4TransitionRouter.ts
@@ -8,6 +8,7 @@ import {
AnalyticsIntegrationExportSource,
Prisma,
} from "@langfuse/shared/src/db";
+import { variableMapping } from "@langfuse/shared";
import type { Session } from "next-auth";
import {
classifyIngestionSdkAttribution,
@@ -40,6 +41,7 @@ const legacyIntegrationExportSources =
]);
const TRACE_EVAL_TARGET = "trace";
+const DATASET_EVAL_TARGET = "dataset";
const isLegacyIntegrationExportSource = (
exportSource: AnalyticsIntegrationExportSource | null | undefined,
@@ -583,15 +585,45 @@ export const v4TransitionRouter = createTRPCRouter({
traceLevelEvalSummary: protectedProjectProcedure
.input(z.object({ projectId: z.string() }))
.query(async ({ input, ctx }) => {
- const traceLevelEvalCount = await ctx.prisma.jobConfiguration.count({
+ // Only active evaluators running on new data require migration;
+ // inactive or backfill-only (EXISTING) configs are not counted.
+ const legacyEvalConfigs = await ctx.prisma.jobConfiguration.findMany({
where: {
projectId: input.projectId,
jobType: "EVAL",
- targetObject: TRACE_EVAL_TARGET,
+ targetObject: { in: [TRACE_EVAL_TARGET, DATASET_EVAL_TARGET] },
+ status: "ACTIVE",
+ timeScope: { has: "NEW" },
},
+ select: { targetObject: true, variableMapping: true },
});
- return { traceLevelEvalCount };
+ // The in-app assistant can only complete the eval migration when every
+ // remaining legacy evaluator is trivially repointable: dataset targets,
+ // or trace targets whose variables all read from one named observation.
+ const allAssistantMigratable =
+ legacyEvalConfigs.length > 0 &&
+ legacyEvalConfigs.every((config) => {
+ if (config.targetObject === DATASET_EVAL_TARGET) return true;
+ const parsed = z
+ .array(variableMapping)
+ .safeParse(config.variableMapping);
+ if (!parsed.success || parsed.data.length === 0) return false;
+ if (
+ parsed.data.some((mapping) => mapping.langfuseObject === "trace")
+ ) {
+ return false;
+ }
+ const observationNames = new Set(
+ parsed.data.map((mapping) => mapping.objectName ?? ""),
+ );
+ return observationNames.size === 1;
+ });
+
+ return {
+ traceLevelEvalCount: legacyEvalConfigs.length,
+ allAssistantMigratable,
+ };
}),
summaryByProject: protectedOrganizationProcedure
@@ -693,12 +725,16 @@ export const v4TransitionRouter = createTRPCRouter({
if (projectIds.length === 0) return [];
+ // Only active evaluators running on new data require migration;
+ // inactive or backfill-only (EXISTING) configs are not counted.
const traceLevelEvalCounts = await ctx.prisma.jobConfiguration.groupBy({
by: ["projectId"],
where: {
projectId: { in: projectIds },
jobType: "EVAL",
- targetObject: TRACE_EVAL_TARGET,
+ targetObject: { in: [TRACE_EVAL_TARGET, DATASET_EVAL_TARGET] },
+ status: "ACTIVE",
+ timeScope: { has: "NEW" },
},
_count: { _all: true },
});
@@ -740,7 +776,9 @@ WITH selected AS (
WHERE je.project_id = ${input.projectId}
AND jc.project_id = ${input.projectId}
AND jc.job_type = 'EVAL'
- AND jc.target_object = ${TRACE_EVAL_TARGET}
+ AND jc.target_object IN (${TRACE_EVAL_TARGET}, ${DATASET_EVAL_TARGET})
+ AND jc.status = 'ACTIVE'
+ AND 'NEW' = ANY(jc.time_scope)
AND je.status != 'CANCELLED'
AND je.created_at >= ${input.fromTimestamp}
AND je.created_at <= ${input.toTimestamp}