text
stringlengths
0
59.1k
criteria: PassCriteriaEvaluation[]; // pass/fail breakdown
}
```
### Item Results
```ts
interface ExperimentItemResult {
item: ExperimentDatasetItem;
itemId: string;
index: number;
status: "passed" | "failed" | "error" | "skipped";
runner: {
output?: unknown;
metadata?: Record<string, unknown> | null;
traceIds?: string[];
error?: unknown;
startedAt: number;
completedAt?: number;
durationMs?: number;
};
scores: Record<string, ExperimentScore>;
thresholdPassed?: boolean | null; // true if all thresholds passed
error?: unknown;
durationMs?: number;
}
```
## Error Handling
### Runner Errors
If the runner throws an exception, the item is marked `status: "error"` and the error is captured in `itemResult.error` and `itemResult.runner.error`.
```ts
runner: async ({ item }) => {
try {
return await agent.generateText(item.input);
} catch (error) {
// Error captured automatically - no need to handle here
throw error;
}
};
```
### Scorer Errors
If a scorer throws, the item is marked `status: "error"`. Individual scorer results include `status: "error"` and the error message.
### Cancellation
Pass an AbortSignal to stop the run early:
```ts
const controller = new AbortController();
setTimeout(() => controller.abort(), 30000); // 30 second timeout
const result = await runExperiment(experiment, {
signal: controller.signal,
});
```
When aborted, `runExperiment` throws the abort reason. Items processed before cancellation are included in the partial result (available via VoltOps if connected).
## Concurrency
Set `concurrency` to process multiple items in parallel:
```ts
const result = await runExperiment(experiment, {
concurrency: 10, // 10 items at once
});
```
Concurrency applies to both runner execution and scoring. Higher values increase throughput but consume more resources. Start with 4-8 and adjust based on rate limits and system capacity.
## Best Practices
### Structure Datasets by Purpose
Group related scenarios in the same dataset:
- `user-onboarding` - Sign-up flows and welcome messages
- `support-faq` - Common questions with known answers
- `edge-cases` - Error handling and unusual inputs
### Use Version Labels
Label dataset versions to track changes:
```ts
dataset: {
name: "support-faq",
metadata: {
version: "2024-01-15",
description: "Added 20 new questions about billing",
},
}
```