@langwatch/scenario
    Preparing search index...

    Class ScenarioExecutionState

    Manages the state of a scenario execution. This class implements the ScenarioExecutionStateLike interface and provides the internal logic for tracking conversation history, turns, results, and other related information.

    Implements

    Index

    Constructors

    Properties

    The scenario configuration.

    description: string

    The scenario description.

    events$: Observable<StateChangeEvent> = ...

    Accessors

    Methods

    • Remove all messages from position index onward.

      Truncates the internal message list and notifies the executor (via the registered rollback handler) to clean pending queues.

      Note: This method is safe to call only during an agent's call() invocation. The executor runs agents sequentially, so no other agent can observe stale newMessages references. Calling this from outside that flow may leave already-delivered newMessages out of sync.

      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.

    • Register a callback that fires when messages are rolled back. The executor uses this to clean up its pending message queues.

      Parameters

      • handler: (removedSet: Set<object>) => void

      Returns void