@langwatch/scenario
    Preparing search index...

    Interface ScenarioExecutionLike

    The execution context for a scenario script. This provides the functions to control the flow of the scenario.

    interface ScenarioExecutionLike {
        messages: ModelMessage[];
        threadId: string;
        agent(content?: string | ModelMessage): Promise<void>;
        agentNonBlocking?(content?: string | ModelMessage): void;
        fail(reasoning?: string): Promise<ScenarioResult>;
        judge(
            options?: {
                additionalContext?: string;
                context?: string;
                criteria?: string[];
            },
        ): Promise<ScenarioResult | null>;
        message(message: ModelMessage): Promise<void>;
        proceed(
            turns?: number,
            onTurn?: (state: ScenarioExecutionStateLike) => void | Promise<void>,
            onStep?: (state: ScenarioExecutionStateLike) => void | Promise<void>,
        ): Promise<ScenarioResult | null>;
        succeed(reasoning?: string): Promise<ScenarioResult>;
        user(content?: string | ModelMessage): Promise<void>;
    }

    Implemented by

    Index
    messages: ModelMessage[]

    The history of messages in the conversation.

    threadId: string

    The ID of the conversation thread.

    • Adds an agent message to the conversation. If no content is provided, the agent under test will generate a message.

      Parameters

      • Optionalcontent: string | ModelMessage

        The content of the agent message.

      Returns Promise<void>

    • Voice-only: fire an agent turn WITHOUT awaiting it — the non-blocking primitive behind agent({ wait: false }) (PRD §4.4). The executor tracks the in-flight turn so a subsequent user call lands as a mid-stream barge-in (interruption) rather than a separate turn. Optional: text-only executors may omit it, in which case the { wait: false } step falls back to a fire-and-forget agent() with no barge-in coordination.

      Parameters

      • Optionalcontent: string | ModelMessage

      Returns void

    • Invokes the judge agent to evaluate the current state.

      Parameters

      • Optionaloptions: { additionalContext?: string; context?: string; criteria?: string[] }

        Optional options with inline criteria and/or additional context.

        • OptionaladditionalContext?: string
        • Optionalcontext?: string

          Use additionalContext instead.

        • Optionalcriteria?: string[]

      Returns Promise<ScenarioResult | null>

      The result of the scenario if the judge makes a final decision.

    • Adds a user message to the conversation. If no content is provided, the user simulator will generate a message.

      Parameters

      • Optionalcontent: string | ModelMessage

        The content of the user message.

      Returns Promise<void>