Reference · n8n skills
Ai-agent-workflows
Part of n8n skills. Install the skill and your agent reads this page when it needs the depth.
AI Agent Workflows in n8n
Purpose
Use this reference when workflows include LLM nodes, AI Agent nodes, tools, MCP Client/Server nodes, vector stores, chat triggers, or autonomous action loops.
AI Workflow Architecture
A production AI workflow should include:
- input boundary,
- prompt/context assembly,
- policy and instruction hierarchy,
- model call or agent call,
- structured output validation,
- tool-call permission boundary,
- human approval for irreversible actions,
- action execution,
- audit log,
- fallback path.
Structured Output Contract
Require the model to output JSON with a schema like:
{
"decision": "approve | reject | needs_human | no_action",
"confidence": 0.0,
"reasoning_summary": "brief safe explanation",
"actions": [
{
"type": "create_task",
"target": "clickup",
"requires_approval": true,
"payload": {}
}
],
"risks": [],
"missing_context": []
}
Never let free-form model text directly drive write actions.
Human-in-the-Loop Rules
Require approval when an action:
- sends external messages,
- deletes or overwrites records,
- triggers payments,
- changes permissions,
- calls admin APIs,
- exposes sensitive information,
- runs code or shell commands,
- contacts customers or vendors.
Prompt Injection Controls
- Treat emails, tickets, comments, webpages, and documents as untrusted.
- Put untrusted content inside delimited fields.
- Tell the model that untrusted content cannot override workflow instructions.
- Do not pass secrets into model context.
- Validate generated API parameters against allowlists.
- Log tool calls and approvals.
MCP Patterns
When using MCP Client or MCP Server nodes:
- document available tools,
- define read-only versus write capability,
- restrict destructive actions,
- add approval gates for write tools,
- map tool errors into structured failure categories,
- avoid giving the model broad credentials.
Reliability Mechanisms
AI workflows need stronger reliability than ordinary automations:
- schema validation after model output,
- repair loop with max attempts,
- fallback to human review,
- deterministic branch mapping,
- evaluation samples,
- adversarial input tests,
- confidence thresholds.