@langwatch/scenario
    Preparing search index...

    Class TwilioAgentAdapter

    Abstract base for voice agents that exchange audio with the agent under test.

    Subclasses must implement connect, disconnect, sendAudio, and receiveAudio. They must also publish an AdapterCapabilities instance as the capabilities field — declared once per concrete adapter, not per instance.

    The default call implementation lives in defaultVoiceCall: it extracts audio from the latest user message, transmits via sendAudio, drains the agent response on tail silence, and records one user + one agent segment into the executor state. Subclasses can override call() for specialised flows but will usually inherit it.

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    accountSid: string
    agentSpeakingEvent?: AgentSpeakingEvent

    Set when the adapter has emitted its first agent audio chunk for the current turn — gates timing-based barge-in. Concrete adapters expose this so scenario.interrupt can wait for real speech before firing the interruption. Optional: adapters without server-VAD-style interrupt sequencing can leave it undefined.

    allowedCallers?: ReadonlySet<string>
    authToken: string
    capabilities: AdapterCapabilities = ...

    Declaration of what this adapter can and cannot do. Concrete subclasses MUST publish a non-default value; the base instance defaults to "nothing supported" so capability-gated steps fail safely when an adapter forgets to declare.

    fetchImpl: (
        input: string | URL | Request,
        init?: RequestInit,
    ) => Promise<Response>
    httpPort: number
    name?: string
    onDtmf?: (digit: string) => void
    phoneNumber: string
    publicBaseUrl?: string
    rejectedCount: number = 0

    Called by the server when an inbound webhook is rejected (caller filter or bad signature). Exposed for tests; production callers see the HTTP response and never look at this counter.

    responseMaxDuration: number = 30.0

    Hard cap on a single agent turn's audio. Prevents runaway loops if a transport never signals end-of-stream. 30s = a long sentence.

    responseTailSilence: number = 0.6

    Tail silence: once the first agent chunk arrives, keep draining receiveAudio until no chunk shows up within this many seconds — that's how we detect the agent finished talking.

    responseTimeout: number = 30.0

    Seconds to wait for agent audio after sending user audio.

    role: AgentRole
    streamingTranscript?: string

    Incremental transcript text emitted while the agent speaks. Populated by adapters that advertise capabilities.streamingTranscripts. Read by scenario.interrupt when afterWords: N is set.

    validateSignature: boolean

    Accessors

    Methods