data/skills/n8n-agents/README.md
The deep guide to designing n8n AI agents and the LangChain family around them (@n8n/n8n-nodes-langchain.*) — the AI Agent node, its model/memory/tools/outputParser slots, and the chains and classifiers you'd reach for instead.
This is the biggest skill in the pack. The parent n8n-workflow-patterns ai_agent_workflow.md gives the high-level "agent in a workflow" shell; this skill goes one level down into how to build it well.
The most common over-build is reaching for an Agent when the job is one-shot:
| You need to… | Use |
|---|---|
| Tools, multi-turn reasoning, or memory | AI Agent (.agent) |
| One-shot text in → text out, no tools | Basic LLM Chain (.chainLlm) |
| Route a natural-language input to one of N branches | Text Classifier (.textClassifier) — NOT Agent + Switch |
| Pull structured fields out of free text | Information Extractor (.informationExtractor) |
| Generate an image / audio / video | The provider's native single-call node — never wrap media in an Agent |
ai_* connection$fromAI() anatomy — how agent-filled tool params are declared (name / description / type); JSON only, never binaryoutputParserStructured + a coding-capable fixer modelmemoryBufferWindow, keyed on a stable session keytool1) or empty descriptionoutputParserStructured without autoFixsessionId or sessionId behind $fromAIActivates when you:
@n8n/n8n-nodes-langchain.* AI node$fromAI, system promptssessionId, structured/JSON output, an output parserExample queries:
tool1. Why?"Main skill content — loaded when the skill activates.
ai_* connection types$fromAI() anatomy| File | Read when |
|---|---|
| TOOLS.md | Choosing among the four tool types, writing names/descriptions, $fromAI anatomy |
| SUBWORKFLOW_AS_TOOL.md | Wiring a sub-workflow as a tool via .toolWorkflow |
| SYSTEM_PROMPT.md | Writing/refactoring a system prompt; the modular split |
| STRUCTURED_OUTPUT.md | Forcing JSON output, autoFix, the fixer model, parse-failure fixes |
| MEMORY.md | Choosing a memory type; persistence and sessionId handling |
| HUMAN_REVIEW.md | Adding human approval; approval-message content; multi-channel approver |
| CHAT_AGENT_PATTERNS.md | Slack/Discord/Teams/Telegram bots; shell + core + sub-agents topology |
| RAG.md | Retrieval-augmented agents (thin by design) |
| EXAMPLES.md | Node-object snippets: stateless agent core, Slack router shell, domain sub-agent |
"Main LLM": { "ai_languageModel": [[{ "node": "AI Agent", "type": "ai_languageModel", "index": 0 }]] }
={{ $fromAI('recipient', 'Email address of the recipient', 'string') }}
={{ $('Chat Trigger').first().json.user.id }}
{ "sessionIdType": "customKey", "sessionKey": "={{ $json.threadId }}", "contextWindowLength": 50 }
$fromAI=Refund {{ $tool.parameters.amount }} to {{ $tool.parameters.customerId }}?
@n8n/n8n-nodes-langchain.agentget_node / validate_node: short form — nodes-langchain.agentn8n-workflow-patterns (ai_agent_workflow.md): the high-level agent shape. Start there for architecture; this skill is the deep dive.
n8n-mcp-tools-expert: node-type formats and tool selection — consult before any MCP call.
n8n-node-configuration: displayOptions-driven fields on the agent and sub-nodes; Slack/Block Kit message shapes.
n8n-expression-syntax: {{ }}, $json.output, $now, $fromAI, $tool.parameters.
n8n-code-tool: the Custom Code Tool's string-in/string-out contract (a different runtime from this skill's tools).
n8n-subworkflows: the sub-workflow primitive .toolWorkflow builds on.
n8n-binary-and-data: owns the agent-tool binary boundary mechanics.
n8n-validation-expert: interpreting validate_workflow, including AI-connection issues (a tool on main instead of ai_tool flags as disconnected).
n8n-error-handling: onError: 'continueErrorOutput' on tool sub-workflows and the agent-core call; error UX on chat shells.
| Need | Use |
|---|---|
| One native node + one operation | Native tool node |
| More than one node / reusable / testable | .toolWorkflow (default when in doubt) |
| A single external HTTP API the agent orchestrates | HTTP Request Tool (.toolHttpRequest) |
| A maintained MCP server / publish n8n logic to many agents | MCP Client Tool |
| Pure inline computation (math, parsing) | Custom Code Tool (.toolCode, see n8n-code-tool) |
Rule of thumb: if you want $fromAI() inside Code, you want .toolWorkflow instead.
After using this skill, you should be able to:
ai_* connection types$fromAI() params well, and plumb identity/limits/sessionId deterministicallyoutputParserStructured with a manual schema + autoFix + a coding-capable fixer$tool.parametersVersion: 1.0.0
Compatibility: n8n with @n8n/n8n-nodes-langchain.agent and the LangChain sub-node family. Node versions and model availability shift between releases — verify on the target instance with search_nodes / get_node.
Remember: the model can't see your wiring — it sees a system prompt and a list of named, described tools. Design those like an API and most "the agent won't behave" problems disappear.