Skip to main content

Model Memory Modes

The UEL Model supports four memory modes that control how conversation history is loaded and saved during chain execution.

Quick Reference

Usage

Mode Details

auto (Default)

Smart detection mode - automatically detects if the input contains placeholder history and adjusts behavior accordingly. Loading:
  • If placeholder history detected → Skip loading from memory
  • If no placeholder history → Load from memory
Saving:
  • Saves only the last request + response (prevents duplicates)
Best for:
  • Multi-chain RAG patterns
  • Complex workflows where same model is used multiple times
  • When you want automatic conflict resolution

always

Always load mode - ignores placeholder detection and always loads from memory.
Can cause duplicate history if used with placeholder-based templates!
Loading:
  • Always loads from memory (ignores placeholder detection)
Saving:
  • Saves only the last request + response
Best for:
  • Simple single-chain chatbots
  • Scenarios where you never use placeholder history

never

Never load mode - never loads from memory but still saves for logging purposes. Loading:
  • Never loads from memory
Saving:
  • Saves only the last request + response
Best for:
  • Analytics and logging
  • When history is always provided via external sources
  • Recording conversations without affecting model context

record_all

Full audit mode - like auto for loading, but saves ALL messages including placeholder history.
Can cause exponential memory growth with duplicates in multi-turn conversations!
Loading:
  • Same as auto (skip if placeholder, load otherwise)
Saving:
  • Saves ALL messages including placeholder history
Best for:
  • Complete audit trails
  • Single-chain scenarios where you need full history recorded
  • Debugging (handle duplicates yourself)

Scenario Behavior Matrix

The table below shows what the model receives during inference for each mode and scenario: Legend:
  • ✅ Optimal behavior
  • ⚠️ Potential issue (duplicates or missing context)

Multi-Chain RAG Pattern

When using the same model in multiple chains (e.g., contextualize + answer), use mode="auto":

Debug Mode

Enable debug logging to see exactly what’s happening:
This will print:
  • Current mode
  • Whether placeholder history is detected
  • Whether memory is loaded or skipped
  • What messages are saved to memory

Key Concepts

Placeholder History vs Model Memory

  • Placeholder History: External history passed via chat_history input parameter
  • Model Memory: Internal storage that accumulates across invocations
When placeholder history is provided, it’s not stored in model memory (except with record_all). This prevents duplication.
  1. Handles both cases: Works with and without placeholder history
  2. Prevents pollution: Same model can be used in multiple chains safely
  3. Minimal memory growth: Only saves new exchanges
  4. Smart detection: Automatically knows when to skip memory loading