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.- All variables are
GATHERfields. COMPLETEreads 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: optionalis never missing. It overridesrequired: 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
activationvalue stays missing for good. See Progressively collect fields only when needed.
- 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, orstrategy. - To capture a volunteered optional value, give the field one of those settings. The example sets
strategy: patternon the phone field, which uses the built-in phone pattern. - A
FLOWstep 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
FLOWstep does not ask for optional fields. A step with only optional fields passes through on entry.
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
Setdefault 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.
Gate a field instead
Useactivation: progressive or a when condition for a field that applies only after another answer. See Progressively collect fields only when needed.
Verification
- Run the validator. Expect no errors and no warnings.
- Say “My order is A100 and it arrived broken”. Expect the agent to log the issue without asking for the phone number.
- Say “My order is A100, it arrived broken, call me on 555 010 2000”. Expect
contact_phoneto fill. - Say only the order number. Expect the agent to ask for the issue.
- In the trace, open the
gather_slot_ledgerevents with the phasecompletion_check.missingFieldsmust list required fields only. - When the trace shows
all_optional_reasoning_gatheras 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: falsetogether with adefault. - Tests cover a customer who gives only required values, all values, and an optional value in the first message.
Common mistakes
Troubleshooting
Related articles: