@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: CoreMessage[];
        threadId: string;
        agent(content?: string | CoreMessage): Promise<void>;
        fail(reasoning?: string): Promise<ScenarioResult>;
        judge(content?: string | CoreMessage): Promise<null | ScenarioResult>;
        message(message: CoreMessage): Promise<void>;
        proceed(
            turns?: number,
            onTurn?: (state: ScenarioExecutionStateLike) => void | Promise<void>,
            onStep?: (state: ScenarioExecutionStateLike) => void | Promise<void>,
        ): Promise<null | ScenarioResult>;
        succeed(reasoning?: string): Promise<ScenarioResult>;
        user(content?: string | CoreMessage): Promise<void>;
    }

    Implemented by

    Index

    Properties

    messages: CoreMessage[]

    The history of messages in the conversation.

    threadId: string

    The ID of the conversation thread.

    Methods

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

      Parameters

      • Optionalcontent: string | CoreMessage

        The content of the agent message.

      Returns Promise<void>

    • Invokes the judge agent to evaluate the current state.

      Parameters

      • Optionalcontent: string | CoreMessage

        Optional message to the judge.

      Returns Promise<null | ScenarioResult>

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

    • Adds a message to the conversation.

      Parameters

      • message: CoreMessage

        The message to add.

      Returns Promise<void>

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

      Parameters

      • Optionalcontent: string | CoreMessage

        The content of the user message.

      Returns Promise<void>