Concept
An entity is a named definition of a value: its type, its allowed values, its synonyms, and its pattern. You declare it once in theENTITIES: section. A GATHER field binds to it with ENTITY_REF. The field then inherits the entity instead of repeating the same settings.
Use an entity when:
- Two or more fields extract the same kind of value.
- A value needs synonyms or a pattern that you want to maintain in one place.
- You want extraction hints that apply wherever the value is used.
GATHER properties when one field needs a simple type and nothing else. See Collect information with global GATHER.
An entity belongs to the agent file that declares it. Declare the entity in each agent that uses it.
Minimal working example
A refund assistant extracts a request type and a booking reference. Both are entities. TwoGATHER fields bind to them.
agents/refund-intake.agent.abl
requestandbookingareGATHERfields that the customer supplies.- The entities supply the type, the allowed values, the synonyms, and the pattern.
How it works
Entity properties. These are the only properties the parser reads:
What a field inherits when it sets
ENTITY_REF:
- The type, the allowed values, and the synonyms.
- The
sensitivesetting, unless the field sets its own. - The pattern, description, and hints, which the runtime reads from the entity at extraction time.
PROMPT, DESCRIPTION, and EXTRACTION_HINTS. The field description overrides the entity description. The field hints merge with the entity hints. An empty hint list on the field clears the inherited hints.
A field cannot set TYPE (other than string) or OPTIONS together with ENTITY_REF. That is a compile error GATHER_ENTITY_REF_CONFLICT. An unknown entity name is a compile error GATHER_ENTITY_REF_UNRESOLVED, and the compiler drops the field.
How the runtime uses entities:
- The runtime extracts values from each customer message. It replaces the observed values on every turn.
- It checks each value against the entity type.
- It assigns a value to a field that is not yet filled. One unique value goes to the first field that references the entity.
- Several values for one field trigger a clarification. Several values for several fields trigger a disambiguation.
- Input longer than 10,000 characters skips extraction.
Common variations
Entities in a FLOW step
AFLOW step GATHER binds to entities the same way.
agents/flow-refund.agent.abl
Override the description on one field
SetDESCRIPTION on a field that uses the entity in a narrower way.
Entities in the NLU section
TheNLU: section can also declare entities. Do not declare the same entity name in both ENTITIES: and NLU:. That is a compile error ENTITY_DUPLICATE_DECLARATION.
Verification
- Run the validator. Expect no errors and no warnings.
- Say “I want my money back for booking AB12345”. Expect
requestto fill asREFUNDandbookingasAB12345, with no questions. - Say only “I want to swap it”. Expect
requestto fill asEXCHANGEand the agent to ask for the booking reference. - In the trace, open the
entity_observationevents for the values found. Openentity_slot_assignmentfor the field each value went to. - Open
entity_validation_intrinsicto see a value that failed the type check.
Production readiness checklist
- Every entity has a
DESCRIPTION. - Every enum entity has
VALUESin one line. - Every field with
ENTITY_REFsets noTYPEorOPTIONS. - The entity is declared in every agent that uses it.
- Each entity name is unique in the file.
- Tests cover a value stated in the first message, a value stated later, and an unknown value.
Common mistakes
Troubleshooting
Related articles: