dataset.listExperimentResults()
Added in: @mastra/core@1.4.0
Lists individual item results for a specific experiment with optional filters and pagination. Filters are applied at the storage layer.
Usage exampleDirect link to Usage example
import { Mastra } from '@mastra/core'
const mastra = new Mastra({
/* storage config */
})
const dataset = await mastra.datasets.get({ id: 'dataset-id' })
const { results, pagination } = await dataset.listExperimentResults({
experimentId: 'exp-id',
page: 0,
perPage: 50,
})
// Restrict to results that still need review
const { results: pending } = await dataset.listExperimentResults({
experimentId: 'exp-id',
status: 'needs-review',
})
// Restrict to results tied to a specific trace
const { results: byTrace } = await dataset.listExperimentResults({
experimentId: 'exp-id',
traceId: 'trace-abc',
})
for (const result of results) {
console.log(`Item ${result.itemId}: ${result.error ? 'FAILED' : 'OK'}`)
}
ParametersDirect link to Parameters
experimentId:
string
ID of the experiment to list results for.
traceId?:
string
Restrict results to those linked to this trace ID.
status?:
'needs-review' | 'reviewed' | 'complete'
Restrict results to this per-result review status.
filters?:
ExperimentTenancyFilters
Multi-tenant scoping filters (
organizationId, projectId). Forwarded to the storage layer.page?:
number
Page number. Defaults to
0.perPage?:
number
Number of results per page. Defaults to
20.ReturnsDirect link to Returns
result:
Promise<object>
Paginated experiment results.
object
results:
ExperimentResult[]
Array of item-level results.
ExperimentResult
id:
string
Unique result ID.
experimentId:
string
ID of the parent experiment.
itemId:
string
ID of the dataset item.
itemDatasetVersion:
number | null
Dataset version of the item when executed.
input:
unknown
Input data passed to the target.
output:
unknown | null
Output from the target.
groundTruth:
unknown | null
Expected output.
error:
{ message: string; stack?: string; code?: string } | null
Structured error if execution failed.
startedAt:
Date
When execution started.
completedAt:
Date
When execution completed.
retryCount:
number
Number of retry attempts.
traceId:
string | null
Trace ID for observability.
createdAt:
Date
When the result record was created.
pagination:
PaginationInfo
Pagination metadata with
total, page, perPage, and hasMore.