Skip to main content
Back to how-to guides Use this pattern when some fields must be collected before the conversation can finish, and others are welcome but not needed.

Concept

A field is required unless you say otherwise. A required field with no value blocks collection. An optional field never blocks it. You have four ways to relax a field. They differ in what the agent does with the field. A field that carries a default counts as filled for completion. The runtime does not write the default into the field, so a reply template that reads the field may show nothing.

Minimal working example

An order support agent requires the order number and the issue. It accepts a callback phone number when the customer offers one. The gift note and callback window are optional.
Variable sources:
  • All variables are GATHER fields.
  • COMPLETE reads the two required fields and the three optional fields. The optional ones can be empty.

How it works

How completion is decided:
  • A required field is missing when it has no value, and no default.
  • activation: optional is never missing. It overrides required: true.
  • A value that failed validation is not stored, so the field stays missing.
  • A value whose source the field does not allow, through satisfied_by, does not count.
  • A field with an invalid activation value stays missing for good. See Progressively collect fields only when needed.
How extraction treats optional fields:
  • A reasoning agent extracts values for all missing fields in one pass before the model replies. A plain optional field is left out of that pass. A plain optional field is one with no extraction_pattern, infer, prompt_mode: extract_only, or strategy.
  • To capture a volunteered optional value, give the field one of those settings. The example sets strategy: pattern on the phone field, which uses the built-in phone pattern.
  • A FLOW step extracts all active step fields in one call, optional ones included, when a model client is wired. Without one, it extracts only the missing fields.
  • A FLOW step does not ask for optional fields. A step with only optional fields passes through on entry.
A reasoning agent lists each field in its prompt as required or optional. The model may ask for an optional field. Do not rely on it.

Common variations

Ask for an optional field in a FLOW

To ask, make the field required in a step of its own, or write a step prompt that mentions it. See Collect information inside a FLOW step.

Optional in a FLOW step with the shorthand

Write - phone: optional in a step. If a top-level GATHER has a field of the same name that is required, the shorthand alone does not override it. Add a property such as prompt.

Use a default

Set default on a field to let completion pass without a value. Remove required: false when you set a default. The compiler warns W822 for both together.
This is a section snippet. Add it to the agent in the minimal example.

Gate a field instead

Use activation: progressive or a when condition for a field that applies only after another answer. See Progressively collect fields only when needed.

Verification

  1. Run the validator. Expect no errors and no warnings.
  2. Say “My order is A100 and it arrived broken”. Expect the agent to log the issue without asking for the phone number.
  3. Say “My order is A100, it arrived broken, call me on 555 010 2000”. Expect contact_phone to fill.
  4. Say only the order number. Expect the agent to ask for the issue.
  5. In the trace, open the gather_slot_ledger events with the phase completion_check. missingFields must list required fields only.
  6. When the trace shows all_optional_reasoning_gather as a skip reason, all missing fields were plain optional fields.

Production readiness checklist

  • Every required field is read by COMPLETE, a flow step, or a route.
  • Every optional field you need to capture has an extraction setting.
  • Every optional field has a safe fallback where templates read it.
  • No field sets required: false together with a default.
  • Tests cover a customer who gives only required values, all values, and an optional value in the first message.

Common mistakes

Troubleshooting

Related articles: