Token Aware Memory
AI-generatedSummary
Provides an n8n AI Memory interface that stores conversation messages in Redis, grouped by workflow, node, and session. It estimates tokens from message length and checks a compression threshold at 80% of Max Tokens, but compression currently uses a fixed placeholder summary rather than calling an LLM.
Inputs
- Max Tokens — Token limit used to set the compression threshold at 80% of this value; defaults to 8000.
- Summarization Prompt — Prompt template intended for compression, with {{conversation}} as the conversation placeholder. When the threshold is reached, the node requires this value, but its current summary implementation does not use it to call an LLM.
- Redis URL (required) — Redis connection URL; defaults to redis://localhost:6379.
- Session ID — Separates memory for different sessions. If blank, a new random session ID is generated each time the node supplies its memory interface.
Output shape
An AI Memory connection exposing methods to load history, save context, clear memory, get token totals, retrieve full history, and disconnect from Redis.
Messages are stored in Redis under keys scoped to workflow ID, node ID, and session ID. History is returned as message objects containing role, content, timestamp, and estimated token count, ordered from long-term to mid-term to short-term storage. On save, the node adds provided input and output as user and assistant messages, then checks the 80% threshold. If reached without a prompt, it errors; when compression runs, it summarizes all but the newest short-term message into a fixed placeholder summary and stores that in mid-term memory.