The four-layer pattern
A valid JSON object is not the same as an approved decision.
01
Parse the shapeRequire the fields and types the next step expects. Reject malformed JSON before any policy decision.
02
Validate the policyCheck allowlisted actions and targets, minimum confidence, and business-specific values deterministically.
03
Route uncertaintySend malformed, low-confidence, or disallowed output to a review path with the issues attached.
04
Act separatelyKeep the credentialed action node downstream. It should run only after an explicit continue decision.
What n8n already provides
Use each control for the problem it is designed to solve.
Structured Output Parser
n8n documents this node as returning fields based on a JSON Schema. It can generate the schema from a JSON example or use a manually defined schema.
That is the right first control for required fields and types. When a schema is generated from an example, n8n treats every example field as mandatory.
Read the official n8n parser documentationAuto-fixing Output Parser
n8n documents this node as wrapping another parser. If the first parser fails, it calls another language model to fix the error.
That can recover formatting, but the repaired object still needs deterministic checks before it can authorize a business action.
Read the official n8n auto-fixing documentationThe gap after parsing
Check meaning and permission, not only syntax.
{
"action": "send_email",
"target": "all_customers",
"confidence": 0.41,
"reason": "Likely renewal reminder"
}{
"accepted": false,
"route": "human_review",
"issues": [
"action_not_allowed",
"target_not_allowed",
"confidence_below_threshold"
],
"external_action_executed": false
}Where human review belongs
Pause consequential tools, even after output validation.
Output gating and tool approval solve different risks.
The policy gate classifies a candidate decision. n8n's human-in-the-loop tool review can then pause a selected tool and ask a person to approve or deny the actual call. n8n recommends this kind of oversight for irreversible, regulated, or high-value actions.
Read the official n8n human-review documentationReady-to-import option
Skip rebuilding the same policy gate from scratch.
Included
- Importable n8n workflow JSON
- Required-field and type validation
- Allowed-action and allowed-target checks
- Minimum-confidence enforcement
- One bounded retry path
- Human-review routing with issue details
Deliberately excluded
- No model or API credentials
- No email, CRM, purchase, or deletion action
- No claim that validation makes an AI output correct
- No replacement for business-specific acceptance tests
Common questions
Before adding another node to the workflow.
Does n8n have a Structured Output Parser?
Yes. Its documented role is returning fields based on a JSON Schema. Use it to enforce the structure the next step expects.
Why validate output after it parses?
A well-formed object can still request a disallowed action, target the wrong system, fall below your confidence threshold, or contain an unsupported business value.
Should every failed parse call another model?
Not automatically. A bounded repair attempt can help with formatting, but repeated retries increase cost and can hide a broken prompt or contract. Stop after the agreed limit and route the unresolved case.
Does the paid workflow perform the action?
No. It returns continue or human_review. A separate, buyer-controlled node must consume that decision and perform any real action.