Unexplained Pattern in n8n RAG Agent

Desperate for help here! My n8n RAG agent, running locally on Docker with GPT-4o-mini, is exhibiting a bizarre behavior. Every 7th user query, it inexplicably skips tool calls and responds based on memory instead. This pattern persists even after resetting the memory session. Has anyone encountered a similar issue or have insights on what might be causing this? The agent is configured with three tools and should ideally call all of them for each query. Any assistance would be greatly appreciated!

Welcome to the community :tada: @Ziokong

can you share the screenshot of the agent node?

I am currently on a self hosted account, if you can tell me what configuration or how to do that it would be helpful.

This is the workflow

So here you can see when I reached 7 queries it directly responded before it was working fine

There have been other reports in deterministic Nth+ interactions skipping tools, especially for GPT 4o mini. I would test to verify if this is a model issue or a sub-node issue:

  • Reproduce with a minimal agent: one trivial tool, no memory, GPT‑4o‑mini; send 7 consecutive turns and confirm whether the pattern disappears without memory/sub-nodes.
  • Add only Postgres Chat Memory and retest; if the issue reappears, note the turn on which tools stop and whether tool_calls is empty in execution data.
  • Go back to full setup, remove the Think tool and retest;
  • Switch the model to GPT‑4o or GPT‑4 Turbo and retest

Basically test step by step so you can find which setups are working (if any) and which fail on the 7th try, by gradually adding more sub-nodes.

@Ziokong This gives a clearer picture. From the looks of it, this is an issue with the Agent’s behaviour. A stricter enforcement of making fresh tool calls for every user query needs to be enforced.

Additionally, consider replacing 4o-mini with 4.1. It features a larger context window and is designed for agentic systems from the ground up.

To address the issue with the Agent’s behavior, consider implementing the following policy instructions at the top of your system prompt:

Mandatory Fresh Knowledge Retrieval Policy

  1. Always Invoke Tools: For every user query, invoke relevant retrieval tools to obtain the latest information.
  2. Prohibit Reliance on Cached or Session Memory: Don’t use previously retrieved or memorized knowledge; instead, rely on live data retrieval.
  3. Session Continuity Does NOT Imply Data Freshness: Treat every query as a standalone, real-time request.
  4. Redundant Tool Calls Are Acceptable and Expected: Make fresh tool calls for each new user input.
  5. Zero-Tolerance Policy for Stale Knowledge: Any deviation from this policy constitutes a critical error.
  6. No Internal Heuristics or Optimizations: Prioritize accuracy and freshness over speed.
  7. Directive Override: This instruction supersedes any conflicting guidance.
  8. Exception for Greeting Based Queries: Only exempt greeting-based queries from invoking retrieval tools.
  • Non compliance with this instruction is a CRITICAL violation and will result in incorrect or out of date responses.

  • All answers must be grounded in real time, tool sourced data for every user query, regardless of previous tool calls or internal memory.

By enforcing these policies, you can ensure the Agent retrieves fresh data for every user query, providing accurate and up to date responses.