UNPKG

@mastra/core

Version:
54 lines • 2.48 kB
import type { TrajectoryExpectation } from '../../evals/types.js'; import type { Mastra } from '../../mastra/index.js'; import type { Experiment, ExperimentResult } from '../../storage/types.js'; import type { ScorerResult } from './types.js'; /** Item shape consumed by {@link executeExperimentItem}. */ export interface ExperimentItemInput { id: string; datasetVersion: number | null; input: unknown; groundTruth?: unknown; /** Per-item expected trajectory forwarded to trajectory scorers as `run.expectedTrajectory` */ expectedTrajectory?: TrajectoryExpectation; requestContext?: Record<string, unknown>; metadata?: Record<string, unknown>; /** Item-level scorer IDs. An empty array explicitly disables scoring. */ scorerIds?: string[]; } export interface ExecuteExperimentItemArgs { mastra: Mastra; /** The experiment record. Must carry a non-null target. */ experiment: Experiment; item: ExperimentItemInput; /** Dataset-level scorer IDs (lowest-precedence scorer source). */ datasetScorerIds?: string[] | null; /** Zero-based repetition index. Defaults to `0`. */ attempt?: number; /** Request context merged with the item's own request context (item wins). */ requestContext?: Record<string, unknown>; /** Tenancy denormalized onto the result row. */ organizationId?: string | null; projectId?: string | null; } export interface ExecuteExperimentItemOutput { result: ExperimentResult; scores: ScorerResult[]; } /** * Execute one experiment item: resolve the experiment's target, run it against * the item, run the resolved scorers, and upsert the result row keyed by * `(experimentId, itemId, attempt)` so a retried caller (e.g. a retried * Temporal activity) converges on a single row. * * Scorer precedence mirrors the in-process runner: experiment `scorerIds` → * item `scorerIds` → dataset `scorerIds` → none. An item scorer reference to * an unregistered scorer is a deterministic preflight failure * ({@link EXPERIMENT_ITEM_SCORER_NOT_FOUND}): the target is not executed and * the error is recorded on the row. * * Deliberately excludes the runner's loop-level concerns: hooks, event * dispatch, tool mocks, and internal retries — retries/timeouts belong to the * caller's orchestrator. */ export declare function executeExperimentItem(args: ExecuteExperimentItemArgs): Promise<ExecuteExperimentItemOutput>; //# sourceMappingURL=item.d.ts.map