Skip to main content

Function: conditional()

conditional(config): Processable<unknown, boolean>

Defined in: packages/core/src/conditional.ts:68

A yes/no decision, answered by whoever is configured to answer it.

A condition is z.boolean().describe(goal) — a constrained schema — so a bounded-decision provider can answer it natively and a model can answer it as structured output. Both are answers to the same question; neither is the primary path.

Which one runs is resolved when the conditional runs, not when it is built, so a pipeline defined before setDefaults() still finds the model, and one invocation can override it through ProcessOptions.defaults.

Parameters

config

ConditionalConfig

Returns

Processable<unknown, boolean>

Example

const isSpam = conditional({ name: 'spam-filter', goal: 'Is this email spam?' });
await isSpam(email); // boolean, from the decision provider or a model