Memory Duplication Issue with Router Agent + Sub-Agent Architecture

I’m experiencing message duplication in my Supabase memory table when using a Router Agent that calls Sub-Agents via AI Agent Tool.

Setup:

  • Router Agent analyzes incoming messages and routes to appropriate sub-agents
  • Sub-Agent handles appointment scheduling tasks
  • Both agents connected to same Postgres Chat Memory node with same session_id

Problem: Every message gets saved twice in the memory table:

  1. Router Agent processes message and saves to memory
  2. Sub-Agent is called and saves the same interaction again
  3. Result: Duplicate entries consuming 2x storage

What I’ve tried:

  • Different session_ids: Creates separate threads but still duplicates storage
  • Memory only on Router: Sub-agent loses conversation context needed for workflow

The dilemma:

  • Router needs memory to track conversation flow
  • Sub-agent needs context to avoid repetitive questions
  • Router only passes current message to sub-agent, not full context

What’s the best practice for sharing memory between Router and Sub-Agents without duplication?


No error message - this is an architecture question about preventing duplicate memory storage.


Current flow: Patient Message → Router Agent (saves to memory) → Sub-Agent via AI Agent Tool (saves to memory again)

Both agents use Postgres Chat Memory connected to Supabase table.


Memory table shows duplicate entries:

Row 670: session_id: main_1 | type: human | content: "I want to schedule"
Row 671: session_id: main_1 | type: ai | content: "Perfect, let me help..."
Row 672: session_id: sub_1 | type: human | content: "I want to schedule" 
Row 673: session_id: sub_1 | type: ai | content: "Perfect, let me help..."

Same conversation, duplicated storage. Looking for n8n-native solution.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.