@langwatch/scenario
    Preparing search index...

    Function agent

    • Generate or specify an agent response in the conversation.

      This is the single agent step for both text and voice scenarios (PRD §9, §6.2; EDR §0). It accepts either response content or a voice-options object:

      • agent() — the agent under test generates its response (blocking).
      • agent("text") / agent(modelMessage) — use the provided content.
      • agent({ wait: false, content? }) — fire the agent turn without awaiting it (the non-blocking voice primitive for interruption / barge-in testing). Control returns immediately so subsequent steps (sleep, silence, user) run while the agent keeps speaking. This is the flagship interruption flow: agent({ wait: false })sleep(n)user("…")agent()judge().

      The two forms are disambiguated structurally: a ModelMessage carries a role discriminant, whereas VoiceAgentOptions ({ wait?, content? }) does not — so a plain options object is never mistaken for a message, and a message is never mistaken for options.

      scenario.voiceAgent is exported as a thin alias of this step for callers that prefer an explicit voice-named symbol; both resolve to the same behavior.

      Parameters

      • Optionalcontent: string | ModelMessage

      Returns ScriptStep

      A ScriptStep function that can be used in scenario scripts.

    • Generate or specify an agent response in the conversation.

      This is the single agent step for both text and voice scenarios (PRD §9, §6.2; EDR §0). It accepts either response content or a voice-options object:

      • agent() — the agent under test generates its response (blocking).
      • agent("text") / agent(modelMessage) — use the provided content.
      • agent({ wait: false, content? }) — fire the agent turn without awaiting it (the non-blocking voice primitive for interruption / barge-in testing). Control returns immediately so subsequent steps (sleep, silence, user) run while the agent keeps speaking. This is the flagship interruption flow: agent({ wait: false })sleep(n)user("…")agent()judge().

      The two forms are disambiguated structurally: a ModelMessage carries a role discriminant, whereas VoiceAgentOptions ({ wait?, content? }) does not — so a plain options object is never mistaken for a message, and a message is never mistaken for options.

      scenario.voiceAgent is exported as a thin alias of this step for callers that prefer an explicit voice-named symbol; both resolve to the same behavior.

      Parameters

      Returns ScriptStep

      A ScriptStep function that can be used in scenario scripts.