Concise, strict adapter for programs with exactly one output field.
Imp.Adapter.Chat deliberately mirrors DSPy's labelled [[ ## field ## ]]
protocol. That is the right compatibility surface for general signatures,
but it is needlessly difficult for small local policies performing ordinary
classification or scalar generation. SingleField is an Imp-native adapter
for that narrower job: it asks for only the output value and maps that value
to the one declared field before applying the normal Imp schema validation.
The parser is intentionally not a repair heuristic. It trims outer
whitespace, but does not strip labels, brackets, quotes, code fences, or
prose. It accepts either the exact scalar value or an exact one-field JSON
object emitted by the response-schema transport. An enum-constrained output
therefore rejects [member], "member", or The answer is member.
Multi-output signatures are rejected before an LM call. Demonstrations must contain every input and the output so the adapter never silently drops partial training context.
LMs that explicitly advertise choice_values support receive the declared
enum members as a content-bound generation constraint. For Imp's local TRL
runtime's deployed greedy mode, the real causal policy scores every declared
token sequence and selects the most likely exact value. Sampled TRL training
deliberately does not advertise this capability: choice-normalized sampling
needs a different policy objective and must not masquerade as ordinary GRPO.
When choice scoring is unavailable but the LM advertises exact response
schemas, SingleField sends the same one-field schema as Imp.Adapter.JSON.
The provider may then return a map, which this adapter validates through the
ordinary typed parser. This is transport constraint, not text repair: an LM
with neither capability still receives only the concise prompt and remains
subject to the exact-value parser.