Skip to content
Français

defineTextResponse

import { defineTextResponse } from "@elie-laloum/outpost";

Declare a response whose value is the trimmed text of the last complete <tag>…</tag> pair. It fails with ResponseError only when no complete pair exists; an invalid tag or repairs fails with code configuration.

Complete example and detailed rules.

  • optionsRequired
    TextResponseOptions
    Tag name and the number of repair turns allowed after an invalid answer.
  • options.tagRequired
    string
    Tag name without angle brackets: a letter followed by letters, digits, _ or -. Another form fails with code configuration.
  • options.repairsOptional
    number | undefined
    Correction turns allowed after an invalid answer, default 0; must be a nonnegative integer. Above 0, the agent must be able to resume its conversation.

ResponseSpec<string>

export declare function defineTextResponse(
  options: TextResponseOptions,
): ResponseSpec<string>;