Skip to main content
Back to how-to guides Use this pattern when customers describe the same thing in different words, units, or spellings, and the agent must store one consistent value.

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 unit and convert_to.
  • Free-text names that must match a list: use a lookup.
There is no general text cleanup. The runtime does not trim, lowercase, or strip punctuation for 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. The semantics 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.
Variable sources:
  • weight and country are GATHER fields that the customer supplies.
  • quote_result comes from the tool call.

How it works

Unit conversion:
  • It runs inside FLOW step GATHER only. A top-level GATHER does 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.
Spoken numbers:
  • 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.
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_match turns 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 sensitive field, a near match counts as a miss.
Tables come from two places. The project runtime configuration holds shared tables under 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.
This is a section snippet. Add it to the agent in the minimal example.

Spoken numbers and phone numbers

Set TYPE: 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

  1. Run the validator. Expect no errors and no warnings.
  2. Say “about 5 kilos, going to Germany”. Expect weight to be about 11 pounds, and country to be Germany.
  3. Say “Germnay”. Expect the agent to ask “Did you mean Germany?” when the table has fuzzy matching on.
  4. Say “Narnia”. Expect an error and a new question.
  5. 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, and lookup_fuzzy_accepted.
  6. Check the stored _original.weight value.

Production readiness checklist

  • Every conversion unit pair is on the supported list.
  • Every conversion happens in a FLOW step.
  • 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 W480 for a large fuzzy table.

Common mistakes

Troubleshooting

Related articles: