@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>;
        fail(reasoning?: string): Promise<ScenarioResult>;
        judge(content?: string | ModelMessage): Promise<null | ScenarioResult>;
        message(message: ModelMessage): 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 | ModelMessage): Promise<void>;
    }

    Implemented by

    Index

    Properties

    messages: ModelMessage[]

    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 | ModelMessage

        The content of the agent message.

      Returns Promise<void>

    • Invokes the judge agent to evaluate the current state.

      Parameters

      • Optionalcontent: string | ModelMessage

        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: ModelMessage

        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 | ModelMessage

        The content of the user message.

      Returns Promise<void>