@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

    _executor: object | null = null

    Back-reference to the ScenarioExecution that owns this state.

    The voice adapter runtime (see voice/adapter.runtime.ts) reads this to reach the executor's import("../voice/voice-executor-state").VoiceExecutorState surface (voiceRecording, voiceTimeline, voiceLatency, etc.). Mirrors Python ScenarioState._executor.

    Underscored to keep callers out of the internal coupling — only the voice subsystem reaches in. Set once by the constructor of ScenarioExecution via setExecutor.

    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.