Search⌘ K
AI Features

Acceptance Criteria That Make JSON Routable

Explore how to establish clear acceptance criteria that produce routable JSON outputs from AI models. Understand how to specify schema constraints, enforce enum values, and handle unknowns with nulls to ensure workflow routers can reliably parse and direct messages. This lesson guides you to transform prompts into testable specifications that improve AI workflow robustness.

AI-generated JSON often fails validation because it is readable to a person but does not conform to the required schema. The output may look valid to a person but still violate the schema a router expects. When a prompt does not define an explicit output contract, the model may add conversational text, return unsupported categories, or include unexpected fields. Consider a representative invalid output that can occur when acceptance criteria are not defined.

Sure, here’s the triage result:

{
"category": "refunds",
"priority": "urgent",
"next_action": "process_refund",
"needs_human": false,
"summary": "Customer wants money back"
}
A bad triage response: Conversational text, invalid values, and an extra key

A workflow router cannot reliably switch on category when it receives refunds instead of an allowed value, and it cannot map priority when it receives urgent. The leading sentence breaks any consumer that expects JSON only, and the extra key summary is a schema drift that forces custom parsing.

Here's what a routable JSON output actually looks like, in contrast to the messy example above:

{
"category": "billing",
"priority": "high",
"next_action": "escalate",
"needs_human": true
}
A valid triage response: Exactly four keys, all allowed values

After those violations are visible, the fix is straightforward. Acceptance criteria turn the triage prompt into a runnable spec by stating what the output must look like so downstream code can reject or route it without interpretation.

Put the contract in the prompt

...