Skip to main content

AI Agent & Memory

Create AI agents that remember context and can reason through complex tasks.

AI Agent Node

The AI Agent is a powerful node that combines an AI model with memory and optional tools for complex reasoning tasks.

Input Handles

HandlePositionPurpose
Main InputLeftUser prompt/data
MemoryBottom-left (diamond)Connect Simple Memory
ModelTop (diamond)Optional model override

Parameters

systemPrompt
string
Instructions that define the agent’s behavior and personality
prompt
string
required
The user message. Supports template variables.
maxIterations
number
default:"5"
Maximum reasoning iterations for complex tasks

Output

{
  "response": "The agent's final response",
  "iterations": 2,
  "reasoning": ["Step 1 thought", "Step 2 thought"]
}

Example Configuration

System Prompt: You are a helpful customer service agent for TechCorp.
              Answer questions about our products and services.
              Be professional and concise.

Prompt: {{webhookTrigger.body.question}}
Max Iterations: 3

Simple Memory Node

Stores conversation history for AI agents, enabling context-aware responses.

Parameters

sessionId
string
default:"default"
Unique identifier for the conversation session
memoryType
select
default:"buffer"
Memory storage mode
windowSize
number
default:"10"
Number of messages to keep (Window mode only)

Memory Types

TypeDescriptionUse Case
BufferKeeps all messagesShort conversations
WindowKeeps last N messagesLong conversations

Connection

Simple Memory connects to the AI Agent’s memory handle (diamond shape on bottom-left):
[Simple Memory] ---(diamond)---> [AI Agent]
Connect to the diamond handle, not the main input. The main input is for data flow.

Session Management

Use dynamic session IDs for multi-user scenarios:
Session ID: {{webhookTrigger.body.user_id}}
This creates separate memory for each user.

Output

Simple Memory is a config node - it doesn’t produce output. The AI Agent reads its configuration directly.

Building an Agent Workflow

Basic Setup

[Webhook Trigger] --> [AI Agent] --> [Webhook Response]
                          ^
                          |
                   [Simple Memory]
                          ^
                          |
                   [OpenAI Chat]

Step-by-Step

  1. Add AI Agent from AI Agents category
  2. Add Simple Memory and connect to memory handle
  3. Add AI Model and connect to model handle (optional)
  4. Add Trigger (Webhook, WhatsApp, etc.) connected to main input
  5. Add Response node connected to agent output

Multi-Turn Conversation Example

First Request

curl -X POST http://localhost:3010/webhook/chat \
  -d '{"user_id": "user123", "message": "My name is Alex"}'
Response: “Nice to meet you, Alex! How can I help you today?”

Second Request

curl -X POST http://localhost:3010/webhook/chat \
  -d '{"user_id": "user123", "message": "What is my name?"}'
Response: “Your name is Alex, as you told me earlier.”

Memory Persistence

  • Memory is stored in SQLite database
  • Survives server restarts
  • Managed automatically by the AI Agent

Clearing Memory

To clear a session’s memory, delete the session from the database or create a new session ID.

Advanced: Window Mode

For long-running conversations, use Window mode to limit memory:
Memory Type: Window
Window Size: 10
This keeps only the last 10 message pairs, preventing context overflow.

Tips

Use descriptive system prompts to define agent behavior clearly.
Set Max Iterations based on task complexity. Simple Q&A: 1-2, Complex reasoning: 3-5.
Use unique Session IDs per user/conversation for proper isolation.
Long conversations with Buffer mode can exceed model context limits. Use Window mode for production.

Troubleshooting

  • Verify Simple Memory is connected to diamond handle (not main input)
  • Check Session ID is consistent across requests
  • Ensure workflow is deployed (not just saved)
  • Check if Session ID changes between requests
  • Verify memory type and window size settings
  • Review system prompt for clarity
  • Switch to Window mode
  • Set appropriate window size (10-20 messages)
  • Consider clearing sessions periodically