Skip to main content

Using Memory in Applications

How to integrate the memory store into Agent applications and workflow applications.

Overview

There are two ways to use memory in applications:
  1. Via the built-in Memory node in Workflow: Configure a workflow that connects Start → SearchMemory (API) → LLM → AddMemory (API) → End.
  2. Via the built-in Memory capability in Agent applications: The application platform automatically manages memory injection.

Using Memory in Workflow Applications

Creating the Workflow

Build the workflow as follows:
Start → SearchMemory (API call) → LLM → AddMemory (API call) → End
The SearchMemory node retrieves relevant historical memories based on the user's input, passes them to the LLM along with the current question, and the AddMemory node writes the new conversation turn back to the memory store.

Key Configuration

  1. SearchMemory node: Set user_id to identify the user, top_k (3-10 recommended).
  2. LLM node: In the prompt, use a variable to reference the retrieved memory context.
  3. AddMemory node: Write the user message and assistant reply.

Prompt Injection

# Memory Context
${memory_search_result}

# Current Question
${user_input}

Using Memory in Agent Applications

Agent applications support two memory modes:

Short-term Memory

Also known as conversation history or multi-turn context. When session_id is passed, the platform automatically maintains the conversation history.
  • Carried context rounds: The number of historical turns passed to the model (0-30). More rounds increase relevance but also input length.

Long-term Memory

For cross-session memory, integrate the memory store API:
  1. Call SearchMemory to retrieve relevant memories.
  2. Inject the results into the system prompt.
  3. After the conversation, call AddMemory to write new memories.
Currently, memory in applications is primarily used via API calls. For the complete API reference, see the Long-term Memory API.