@langwatch/scenario
    Preparing search index...

    Interface EvaluatorState

    The state the evaluator runner resolves mappings against.

    interface EvaluatorState {
        config: ScenarioConfig;
        contexts: string[];
        criteria: string[];
        description: string;
        fields: Record<string, ScenarioFieldValue>;
        spans: ReadableSpan[];
        traces: TraceView[];
        turns: TurnView[];
        get currentTurn(): number;
        get messages(): ModelMessage[];
        get threadId(): string;
        addMessage(message: ModelMessage): void;
        field(name: string): ScenarioFieldValue | undefined;
        firstUserMessage(): string;
        hasToolCall(toolName: string): boolean;
        lastAgentMessage(): AssistantModelMessage;
        lastMessage(): ModelMessage;
        lastToolCall(toolName: string): ToolModelMessage;
        lastUserMessage(): UserModelMessage;
        rollbackMessagesTo(index: number): ModelMessage[];
        startReadTracking(): void;
        takeReads(): StateReads;
        toolCalls(name?: string): ToolCalls;
        transcript(): string;
    }

    Hierarchy (View Summary)

    Index

    The scenario configuration.

    contexts: string[]

    Every chunk the agent retrieved across the run so far, from the rag spans of the traces.

    criteria: string[]

    The judge criteria of the scenario, in order.

    description: string

    The scenario description.

    fields: Record<string, ScenarioFieldValue>

    The fields the scenario carries next to its description, its data row.

    spans: ReadableSpan[]

    Every span of every trace of the run collected so far, in start order. Never fetches: a script step reads what the collector holds.

    traces: TraceView[]

    One entry per trace id the messages carry, in first-seen order.

    turns: TurnView[]

    One entry per turn, with the messages added during it.

    • Remove all messages from position index onward.

      Truncates the message list and cleans up any pending message queues so no agent sees stale messages.

      Parameters

      • index: number

        Truncate point (clamped to [0, messages.length]). Messages at positions >= index are removed.

      Returns ModelMessage[]

      The removed messages (empty array if nothing to remove).

      If index is negative.