Skip to content

Constrain AI classifications to exact enum values

Guarantee downstream switch statements never break by locking category, priority, and routing keys to strict string enums.

Copy the prompt and paste it into the AI assistant you already use.

Best practices for enum-locked endpoints

  1. 01

    Include an explicit fallback enum

    Provide an other or unknown enum value so the model never forces a wrong fit on weird inputs.

  2. 02

    Use clear kebab or snake case

    Match enum values verbatim to database constants and workflow router branch names.

  3. 03

    Document boundary definitions

    Write one-sentence disambiguation notes explaining where overlapping categories differ.

  4. 04

    Verify enum coverage in evals

    Test ambiguous inputs in eval suites to confirm rare edge classes are routed predictably.

How it works in practice

Input Event & Allowed Enums

Enums: ["sso_setup", "billing_seat", "api_timeout", "feature_gap", "other"] Text: "Okta SAML login keeps redirecting to /error after adding domain."

Strict Enum Response

{ "route_enum": "sso_setup", "secondary_tag": null, "confidence": 0.98 }

Your switch-case router receives exact constant strings 100% of the time—never "SSO Issue" or "Authentication".

Common questions

Will the model ever invent a synonym outside my enum list?

No. Enum schema constraints restrict token generation and gateway validation to your exact string constants.

Can I nest enums inside arrays for multi-tagging?

Yes. You can constrain array items to an enum list and even cap minItems and maxItems per response.

What if we add a seventh category next month?

Update the enum list in a draft endpoint version, validate it with evals, and promote the new contract cleanly.