Memory Workflow

Use a sub-workflow as chat memory storage

Memory Workflow

AI-generated

Summary

Provides a LangChain buffer-window memory backed by a user-selected sub-workflow that acts as the storage layer for chat history.

Inputs

  • Workflow (required) — The workflow to execute for memory operations. It is called with a JSON item containing action, sessionId, and, for add operations, a message object. The node reads the first item of the first branch of the executed workflow's result and uses that JSON as the response.
  • Session ID (required) — Unique identifier for the conversation session. It is passed unchanged on every get/add/clear call to the selected workflow, so it determines which conversation history is read or written.
  • Context Window Length — Number of previous messages to include as context. Passed as k to BufferWindowMemory, controlling how many recent messages are returned to the AI model.
  • Additional Parameters — Optional name/value pairs merged into every sub-workflow call as extra JSON fields. Useful for passing storage identifiers, user IDs, or other context to the selected workflow. Internal action fields (action, sessionId, message) take precedence on name collisions.

Output shape

BufferWindowMemory with memoryKey 'chat_history', returnMessages true, inputKey 'input', outputKey 'output', and k equal to Context Window Length.

Supplies a LangChain BufferWindowMemory object on the Memory (ai_memory) output, not a normal JSON payload. It is intended for connection to an AI Agent's memory input.

Examples

Example 1: Store and retrieve conversation history for a chat session by delegating get/add/clear operations to a selected sub-workflow.

Configure the Memory Workflow node with a workflow that persists chat messages, a session ID, and a context window length; then connect it to an AI Agent's memory input.

Links

Discussion