Concept
Normalization turns what the customer said into the value your agent stores. The runtime applies several layers in order. You control each layer with a different setting.
Pick the layer by what varies:
- Different words for one choice: use an enum with synonyms.
- Different forms of a number, a date, or a phone: set the
TYPE. - Different units: set
unitandconvert_to. - Free-text names that must match a list: use a lookup.
string fields, except that it lowercases an email and matches enum values without regard to case.
Minimal working example
A parcel quote agent reads the weight in kilograms and converts it to pounds for the pricing tool. It also checks the destination country against a list. Thesemantics lookup name supported_countries refers to a project-level lookup table. That table is a project-local assumption. Create it in the project runtime configuration. See Lookup tables. The tool is also a project-local assumption. Bind it to your pricing service in Project Tools.
weightandcountryareGATHERfields that the customer supplies.quote_resultcomes from the tool call.
How it works
Unit conversion:- It runs inside
FLOWstepGATHERonly. A top-levelGATHERdoes not convert. - It converts numbers only. A list or a range is skipped.
- The runtime keeps the original value under
_original.<field>. - A unit pair it does not support is skipped without an error.
- Supported units: temperature (celsius, fahrenheit, kelvin), distance (meters, km, miles, feet, yards), weight (grams, kg, lbs, ounces), time (seconds, minutes, hours, days), volume (ml, liters, gallons, cups), and currency (USD, EUR, GBP, JPY, CAD, AUD, CHF, CNY, INR, MXN, BRL, KRW, SGD, HKD, SEK, NOK). Currency conversion uses static rates unless a live currency client is configured.
- The runtime reads “twenty five” as 25, and “double oh seven” as digits, for numeric fields. It applies this when at least one field in the agent is numeric.
- An enum entity maps each synonym to the canonical value. See Use enum entities with synonyms.
Lookup tables
A lookup check compares the value with a reference list.- An exact match, ignoring case, is stored with the casing of the table.
- A near match, found with a text similarity score, asks “Did you mean X?”. The runtime never applies a near match without the customer’s confirmation. The table setting
fuzzy_matchturns this on. - A value with no match is an error, and the agent asks again.
- A small table is passed to the model as a list of allowed values. A large table gives the model a sample.
- For a
sensitivefield, a near match counts as a miss.
lookup_tables. An agent can also declare LOOKUP_TABLES: in the file. The compiler marks that form as experimental with the warning AGENT_LOOKUP_TABLE_EXPERIMENTAL, and recommends the project tables. A table name uses lowercase letters, digits, and underscores. If a field names a table that does not exist, the runtime skips the check without an error.
Common variations
Agent-local lookup table
Declare the table in the agent when you cannot use project configuration. Expect the experimental warning.Spoken numbers and phone numbers
SetTYPE: number or TYPE: phone. The runtime reads “oh” as 0 and “double” as a repeated digit. A phone becomes an E.164 number. See Extract dates, numbers, locations, and free text.
A synonym map for a choice
Use an enum entity when customers choose among a few options with many phrasings, such as delivery speeds.Verification
- Run the validator. Expect no errors and no warnings.
- Say “about 5 kilos, going to Germany”. Expect
weightto be about 11 pounds, andcountryto beGermany. - Say “Germnay”. Expect the agent to ask “Did you mean Germany?” when the table has fuzzy matching on.
- Say “Narnia”. Expect an error and a new question.
- In the trace, open the extraction resolution result for the raw phrase and the normalized value. Look for the lookup events
lookup_validation_failed,lookup_fuzzy_confirmation_requested, andlookup_fuzzy_accepted. - Check the stored
_original.weightvalue.
Production readiness checklist
- Every conversion unit pair is on the supported list.
- Every conversion happens in a
FLOWstep. - Every lookup table exists in the project, or in the agent, and its name matches.
- Fuzzy matching is on only where a wrong near match is harmless, because the customer confirms it.
- Tests cover a spoken number, a unit conversion, a near match, and a miss.
- Tables with more than 1000 values are tested for speed. The compiler warns
W480for a large fuzzy table.
Common mistakes
Troubleshooting
Related articles: