Skip to main content
Back to how-to guides Use this pattern when an agent must collect several values in conversation and the model, not a fixed script, decides how to ask for them.

Concept

A global GATHER is the top-level GATHER: section of an agent. It declares the fields the agent needs. The runtime does the collection work around the model:
  1. It lists the fields in the agent prompt, in declaration order, and marks each as required or optional.
  2. On each customer message, it extracts values for all missing fields in one pass.
  3. It validates each value and stores the good ones.
  4. The model asks for whatever is still missing.
The order of questions is the model’s choice. The runtime does not run fields in a fixed sequence. For a fixed sequence, use a GATHER inside a FLOW step. See Collect information inside a FLOW step. Completion is separate from collection. A COMPLETE rule fires when its WHEN condition is true. Write that condition on the fields you need, for example amount IS SET.

Minimal working example

A transfer assistant collects the source account, amount, and date. The memo is optional. agents/transfer-intake.agent.abl
Variable sources:
  • All four variables are GATHER fields that the customer supplies.
  • COMPLETE reads the three required fields. The memo is optional and does not block completion.

How it works

Field syntax:
  • Write each field as a named block: the field name, a colon, and indented properties. The name uses letters, digits, and underscores. A name with a hyphen or a dot is not recognized.
  • Property keys are case-insensitive.
  • A list form such as - amount: required does not work in a top-level GATHER. It produces no fields and no error. Use the list form only inside a FLOW step.
  • An inline form such as GATHER: a, b is a compile error.
Important defaults and rules: How the runtime normalizes a value:
  • integer, number, float, and currency become numbers.
  • boolean accepts true, yes, 1, and false, no, 0.
  • date and datetime become ISO values. semantics.temporal: past or future limits the direction.
  • email is lowercased. phone becomes an E.164 number, with the US as the default country.
  • enum is matched to options and synonyms.
How completion is checked:

Common variations

Validate a value and retry

Add validate and a retry_prompt for a value with a fixed format. On a failure the model receives the field error and the retry prompt as a hint, and asks again. max_retries counts failed attempts and records them in the trace. It does not stop the agent from asking, and it does not run an ON_ERROR action. To escalate after repeated failures, collect the field in a FLOW step. See Collect information inside a FLOW step. agents/claim-intake.agent.abl
Rules for validate:
  • Write a regular expression with a single backslash, such as ^\d{9}$. A double backslash is kept as two characters and never matches.
  • A regular expression check rejects every value of type number, integer, currency, or boolean, because those values are not text. Validate those types with type and semantics, or collect the value as string.
  • validate: min(1) is read as a regular expression, not as a numeric minimum.
  • retry_prompt, max_retries, or validation_process without a validate is a compile error GATHER_VALIDATION_RULE_REQUIRED.
  • An unsafe expression, such as (a+)+$, fails compilation.
On a reasoning agent, the platform counts failed attempts per field and records a validation_max_retries trace event when the limit is reached. It resolves a matching ON_ERROR rule and applies its SET assignments, but it does not run the rule’s RESPOND, ESCALATE, or COMPLETE action. With inline_gather: true it does not resolve ON_ERROR at all. The retry-limit action runs only in a FLOW step.

A supervisor that collects first

A SUPERVISOR can declare GATHER. Use it when routing needs a value, such as a policy number. See Pass specific fields between agents.

Collect several fields in one reply

Add description and extraction_hints to guide extraction, or set inline_gather. See Collect multiple fields across a natural conversation.

Verification

  1. Run the validator. Expect no errors and no warnings.
  2. Say “I want to send 200 dollars”. Expect the agent to ask for the source account and the date, and not for the amount.
  3. Give a bad value for a validated field. Expect the agent to explain the format from the retry_prompt.
  4. Give all required values. Expect the COMPLETE reply.
  5. In the trace, open the dsl_collect events with the mode reasoning_gather. They list the extracted fields.
  6. Open the completion_check event for the completion decision.

Production readiness checklist

  • Every field has a prompt and a type.
  • Every required field is read by COMPLETE, a flow step, or a route. Otherwise the compiler warns UNUSED_REQUIRED_GATHER_FIELD.
  • Formats use single-backslash regular expressions.
  • Fields with a fixed format have a retry_prompt. A field that must escalate after repeated failures is collected in a FLOW step.
  • Tests cover a customer who gives everything at once, one value at a time, and an invalid value.
  • Field names are not user_id, session_id, tenant_id, or project_id. The compiler warns SYSTEM_IDENTIFIER_SHADOW for them.

Common mistakes

Troubleshooting

Related articles: