Skip to content

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

fix(mcp,api): Ensure consistent ordering (#13856)

Ben Bachem6a32893eb43f
diff --git a/web/src/features/mcp/features/datasets/tools/listDatasetRuns.ts b/web/src/features/mcp/features/datasets/tools/listDatasetRuns.ts
index 324eba0bbd..2980da87df 100644
--- a/web/src/features/mcp/features/datasets/tools/listDatasetRuns.ts
+++ b/web/src/features/mcp/features/datasets/tools/listDatasetRuns.ts
@@ -31,7 +31,7 @@ export const [listDatasetRunsTool, handleListDatasetRuns] = defineTool({
where: { projectId: context.projectId },
take: input.limit,
skip: (input.page - 1) * input.limit,
- orderBy: { createdAt: "desc" },
+ orderBy: [{ createdAt: "desc" }, { id: "asc" }],
},
},
});
diff --git a/web/src/features/mcp/features/datasets/tools/listDatasets.ts b/web/src/features/mcp/features/datasets/tools/listDatasets.ts
index 886ef99dfe..793377b168 100644
--- a/web/src/features/mcp/features/datasets/tools/listDatasets.ts
+++ b/web/src/features/mcp/features/datasets/tools/listDatasets.ts
@@ -36,7 +36,7 @@ export const [listDatasetsTool, handleListDatasets] = defineTool({
id: true,
},
where: { projectId: context.projectId },
- orderBy: { createdAt: "desc" },
+ orderBy: [{ createdAt: "desc" }, { id: "asc" }],
take: input.limit,
skip: (input.page - 1) * input.limit,
}),
diff --git a/web/src/pages/api/public/datasets/[name]/runs/index.ts b/web/src/pages/api/public/datasets/[name]/runs/index.ts
index 8e603c0acb..0b6a4ce52d 100644
--- a/web/src/pages/api/public/datasets/[name]/runs/index.ts
+++ b/web/src/pages/api/public/datasets/[name]/runs/index.ts
@@ -24,9 +24,7 @@ export default withMiddlewares({
datasetRuns: {
take: query.limit,
skip: (query.page - 1) * query.limit,
- orderBy: {
- createdAt: "desc",
- },
+ orderBy: [{ createdAt: "desc" }, { id: "asc" }],
},
},
});
diff --git a/web/src/pages/api/public/datasets/index.ts b/web/src/pages/api/public/datasets/index.ts
index ccfbc0b507..983de6b259 100644
--- a/web/src/pages/api/public/datasets/index.ts
+++ b/web/src/pages/api/public/datasets/index.ts
@@ -76,17 +76,13 @@ export default withMiddlewares({
select: {
name: true,
},
- orderBy: {
- createdAt: "desc",
- },
+ orderBy: [{ createdAt: "desc" }, { id: "asc" }],
},
},
where: {
projectId: auth.scope.projectId,
},
- orderBy: {
- createdAt: "desc",
- },
+ orderBy: [{ createdAt: "desc" }, { id: "asc" }],
take: limit,
skip: (page - 1) * limit,
});
diff --git a/web/src/pages/api/public/v2/datasets/index.ts b/web/src/pages/api/public/v2/datasets/index.ts
index a67b778164..5ac45fa55b 100644
--- a/web/src/pages/api/public/v2/datasets/index.ts
+++ b/web/src/pages/api/public/v2/datasets/index.ts
@@ -66,9 +66,7 @@ export default withMiddlewares({
where: {
projectId: auth.scope.projectId,
},
- orderBy: {
- createdAt: "desc",
- },
+ orderBy: [{ createdAt: "desc" }, { id: "asc" }],
take: query.limit,
skip: (query.page - 1) * query.limit,
});