Skip to content

AI Agent Streaming Bug - Postgres Chat Memory ignores contextWindowLength with streaming webhooks #18024

Description

@storyguy88

Bug Description

We've been experimenting with the much appreciated new streaming feature.

However, when streaming is enabled, Postgres Chat Memory node fails to respect contextWindowLength, storing unlimited conversation history instead of the given limit.

Environment

  • @n8n/n8n-nodes-langchain.memoryPostgresChat v1.3
  • PostgreSQL database
  • Affects: AI Agent + Webhook streaming combination

To Reproduce

  1. Create workflow with:

    • Webhook: responseMode: "streaming"
    • AI Agent: enableStreaming: true
    • Postgres Chat Memory: contextWindowLength: 2
  2. Send 5+ messages with same sessionId

  3. Verify AI responses reference messages beyond 2-message limit

Results:

  • ❌ Webhook streaming: Ignores context limit
  • ✅ Webhook responseNode: Works correctly, respects limit
  • ✅ Chat Trigger: Works correctly, respects limit

Expected behavior

Expected: Memory limited to specified most recent interactions
Actual: Unlimited conversation history available to AI Agent

Debug Info

Debug info

core

  • n8nVersion: 1.105.2
  • platform: docker (cloud)
  • nodeJsVersion: 22.17.0
  • database: sqlite
  • executionMode: regular
  • concurrency: 5
  • license: community
  • consumerId: 00000000-0000-0000-0000-000000000000

storage

  • success: all
  • error: all
  • progress: false
  • manual: true
  • binaryMode: filesystem

pruning

  • enabled: true
  • maxAge: 168 hours
  • maxCount: 2500 executions

client

  • userAgent: mozilla/5.0 (macintosh; intel mac os x 10_15_7) applewebkit/537.36 (khtml, like gecko) chrome/138.0.0.0 safari/537.36
  • isTouchDevice: false

Generated at: 2025-08-05T19:37:36.564Z

Operating System

macintosh

n8n Version

1.105.2

Node.js Version

22.17.0

Database

PostgreSQL

Execution mode

main (default)

Hosting

n8n cloud

Metadata

Metadata

Assignees

No one assigned

    Labels

    in linearDEPRECATEDteam:aiIssue is with the AI team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions