Search⌘ K
AI Features

Acceptance Criteria That Make JSON Routable

Explore how to create clear acceptance criteria that make AI-generated JSON outputs valid and routable. Understand how to restrict JSON structure, enforce enums, use null for unknowns, and prevent schema drift. This lesson helps you design prompts that produce consistent, machine-readable outputs essential for stable workflow automation.

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

With the failure modes clear, the ...