Skip to main content

The problem

Your lead-scoring prompt returns this:
The JSON is valid and the fields have the right types. The values disagree: a hot lead should have a stronger score, a qualified lead should meet your threshold, and the decision needs a reason. If this reaches your CRM, the system looks correct while sales works the wrong queue.

The contract

Rules should cover the values that decide routing, priority, ownership, or side effects. Keep them synchronous and make the failure message useful enough for a retry.

Run the model

Call your provider inside accept(). Include attempt.instructions in the prompt and add attempt.repairs on every attempt.
On a failing first attempt, Boundary sends the model the exact schema and rule violations. A second attempt can repair the output without your app accepting the bad first value.

Accept or reject

Do not write rejected cleaned data to the CRM as a fallback. If the contract rejects, the workflow should fail closed, retry with more context, or route to review.

When to use this pattern

  • Lead scoring and qualification
  • CRM enrichment before ownership assignment
  • Sales routing and prioritization
  • Any classification that changes queues, SLAs, or customer state