npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

n8n-nodes-advanced-ai-agent

v0.1.1

Published

Advanced AI Agent node for n8n with output validation (code checkers + AI validator), automatic retries with error feedback, required-tool-call enforcement, and structured JSON output via a formatter model

Readme

n8n-nodes-advanced-ai-agent

An Advanced AI Agent community node for n8n — a tools agent with a built-in quality-control loop:

  • Code Validation — run your own JavaScript checks on the agent's answer and its tool calls. On failure the agent is automatically retried with your error message as feedback.
  • 🤖 AI Validation — a second (or the same) chat model reviews the answer against a detailed, editable rubric. It sees the client message, the final answer, every tool call (name, arguments, result), and the agent's reasoning — so it can catch things like "you confirmed the order but never called the create_order tool". Rejections trigger a retry with the validator's feedback.
  • 📦 Structured Output — a formatter model converts the final validated answer into JSON matching an example you provide, with its own retry loop on parse/structure errors.
  • 🎛️ All three features are independent toggles. Extra model inputs (Validator / Formatter) only appear on the canvas when enabled.

How the retry loop works

input ──► Agent run ──► code check ──► AI validator ──► pass ──► formatter ──► output
              ▲              │               │
              └── feedback ◄─┴───── fail ────┘   (up to "Validation Retries" times)

On every failed check the agent is re-invoked with the conversation so far plus the failed answer and the feedback ("Your previous answer was rejected... you must call the create_order tool..."). Failed attempts are never saved to connected Memory — only the original input and the final answer are.

Installation

Self-hosted n8n → Settings → Community Nodes → Installn8n-nodes-advanced-ai-agent.

Or manually: npm install n8n-nodes-advanced-ai-agent in your n8n installation's ~/.n8n/nodes directory.

Connections

| Input | Type | When | |---|---|---| | Chat Model | ai_languageModel | always (required) | | Memory | ai_memory | optional | | Tool | ai_tool | optional, multiple | | Validator Model | ai_languageModel | when AI Validation is on and Use Main Model as Validator is off | | Formatter Model | ai_languageModel | when Structured Output is on and Use Main Model as Formatter is off |

Code Validation contract

Your JavaScript gets these variables:

| Variable | Type | Meaning | |---|---|---| | $input | string | the user message | | $output | string | the agent's final answer | | $toolCalls | array | [{ tool, args, result }, ...] — every tool the agent called | | $reasoning | string | the agent's intermediate reasoning | | $json | object | the incoming item's JSON |

Return true (or nothing) to pass. Return an error-message string (or throw) to fail — that message is sent to the agent as retry feedback, so make it actionable:

if (/order|buy/i.test($input) && !$toolCalls.some((c) => c.tool === 'create_order')) {
  return 'The client asked to place an order but you never called the create_order tool. ' +
    'Call create_order with the requested items, then confirm the order to the client.';
}
return true;

Output

{
  "output": "final answer text",
  "validationPassed": true,
  "attempts": 2,
  "validationLog": [{ "attempt": 1, "source": "ai", "feedback": "..." }],
  "structuredOutput": { "reply": "...", "orderCreated": true },
  "toolCalls": [],
  "reasoning": ""
}

structuredOutput appears when the toggle is on; toolCalls/reasoning when Include Trace in Output is on. With On Validation Failure → Continue, exhausted retries emit the last answer with validationPassed: false instead of failing the node.

Notes

  • Requires self-hosted n8n (community nodes with external dependencies are not available on n8n Cloud).
  • The agent's "reasoning" is what LangChain captures between tool calls; providers' hidden native reasoning tokens are not always exposed by chat-model sub-nodes. Design validator rules to lean primarily on toolCalls + output.

License

MIT