Tune.Adapter.XML (Tune v0.5.0)

Copy Markdown View Source

DSPy-style XML format with schema-directed field delimiters.

Each field is wrapped in <name> and </name>. Values are rendered from the declared schema:

  • strings, string enums, and string literals are raw, unescaped text
  • numbers, booleans, null, and non-string literals are JSON text
  • objects with declared keys are nested <key> elements in declared order
  • arrays are repeated <item> elements
  • string-keyed records are JSON text, because their keys are data

Parsing follows the same schema. It is not a general XML parser: there is no entity expansion, no DTD processing, no attributes, and no namespaces, so &amp; and <!DOCTYPE ...> stay literal text. A string field ends at the first matching closing tag, so string values that contain their own closing tag are rejected when rendering. Each output field must appear exactly once.

Options:

  • :max_reply_bytes - reply size limit, default 1 000 000
  • :max_depth - nesting limit for objects and arrays, default 32

Differences from DSPy 3.5: field types use JSON names and JSON Schema; nested values follow the declared Zoi schema rather than Python type annotations; non-string scalars are strict JSON without repair.