Memory Banks

Memory Banks

Overview

Memory banks give your agents persistent memory. Each bank stores embedded entries that agents can write to, search, and load across runs — enabling patterns like preference learning, progressive summarization, and context enrichment.

There are two types of memory banks:

  • Conversation — stores dialogue turns keyed by key and speaker. Ideal for chat history, multi-turn dialogue, and per-session context.
  • General — stores standalone knowledge keyed by key (no speaker). Ideal for long-term facts, persona definitions, and entity extraction.

Both types use the same unified agent steps — Write Memory, Search Memory, and Load Memory — which accept a key parameter that maps to the appropriate key field based on bank type.

A memory bank controls:

  • Embedding configuration — model, vector dimensions, chunk size/overlap
  • Compaction settings — a prompt and thresholds that trigger automatic summarization
  • Retention — how long entries are kept before automatic cleanup

Memory banks are created and managed from the Memory Banks page in the dashboard, or via the Public API and MCP tools.

Types

Every memory bank has a type that determines what kind of entries it stores and which agent steps can use it.

TypeKey FieldSpeakerAgent StepsBest For
ConversationkeyYesWrite Memory, Search Memory, Load MemoryDialogue history, chat sessions, per-user conversations
GeneralkeyNoWrite Memory, Search Memory, Load MemoryStandalone knowledge, facts, preferences, entity extraction

Conversation banks model multi-turn dialogue. Each entry records who said what with a speaker field, and the Load Memory step can retrieve the entire thread in order — making it suitable for chat history, progressive summarization, and agent prompt injection as messages.

General banks store standalone knowledge entries. There is no speaker, and entries are grouped by key for scoping. Use general banks for long-term facts, persona definitions, extracted entities, and any non-conversational data.

The type is set at creation time (or auto-selected by the template) and cannot be changed after creation.

Creating a Memory Bank

  1. Navigate to Memory Banks in the sidebar
  2. Click Create Memory Bank
  3. Choose a template to prepopulate recommended settings, or click Use AI assistant to describe what you need and let it suggest a configuration
  4. Set a name, mode, compaction prompt, and retention
  5. Optionally click Test Prompt next to the compaction prompt to verify it produces good summaries before creating the bank
  6. Click Create

The bank's content source (where entries are physically stored) is provisioned automatically when the bank is created — no manual source or knowledge base setup required.

Templates

Templates prepopulate the form with recommended settings for common memory patterns:

TemplateTypeBest ForModeRetention
Working MemoryConversationActive task context — requirements, decisions, next stepsFast & Cheap7 days
Short Term MemoryConversationCurrent conversation session contextBalanced30 days
Long Term MemoryGeneralUser preferences, history, and patterns across sessionsSlow & ThoroughIndefinite
Persona MemoryGeneralConsistent agent personality and role definitionBalancedIndefinite
Episodic MemoryConversationTask sequences, outcomes, and lessons learnedBalanced90 days
Entity MemoryGeneralPeople, places, organizations, and eventsSlow & ThoroughIndefinite

Templates are starting points — all settings can be customized after selection.

Modes

The mode controls the embedding dimensions and chunking parameters:

ModeDimensionsChunk SizeChunk OverlapTrade-off
Fast & Cheap2562000400Lowest cost, fastest search, less nuanced recall
Balanced5121500300Good middle ground for most use cases
Slow & Thorough10241000200Best recall quality, higher cost and slower search
CustomChoose your ownChooseChooseFull control over the embedding model and chunking

Mode cannot be changed after creation because the content source's embedding dimensions are locked once provisioned.

Detail Page

Opening a memory bank shows a detail page with three tabs:

  • Entries — Statistics dashboard showing how entries are distributed across conversations/groups, speakers, tags, and time
  • Agents — Lists all agents that currently reference this memory bank, with links to open each agent
  • Configuration — All editable settings (name, description, compaction prompt, thresholds, retention), plus the AI Assistant, Test Compaction Prompt, content source management, and the Delete button

Entry Statistics

The Entries tab shows aggregated statistics (not individual entries) to help you understand how the bank is being used and whether compaction settings need tuning.

Use the time frame selector at the top to filter statistics to a specific date range (default: last 30 days).

  • Summary cards — Total entries, unique conversations (or groups), unique speakers (conversation banks only), date range, and compaction summary count (when compaction has occurred) with the last compaction timestamp
  • Distribution metrics — Token count, entry age, and entries-per-key distributions showing average, p95, min, and max values — useful for spotting outliers and tuning compaction thresholds
  • Breakdown tables — Top conversations/groups by entry count, top speakers, and top tags

These statistics are computed server-side. Individual entry content can be viewed from the linked content source.

Compaction

Compaction prevents memory from growing without bound. Configure a compaction prompt that tells the system how to summarize entries when a threshold is reached.

Triggers — compaction runs when any threshold is exceeded:

ThresholdDescription
Max Age (days)Compact entries older than this many days
Max Size (tokens)Compact when total token count exceeds this
Max TurnsCompact when entry count exceeds this

If no thresholds are set, compaction never runs and entries accumulate indefinitely (subject to retention cleanup).

When compaction runs — compaction is triggered in two ways:

  1. Inline after writes — every time an agent writes a new entry via Write Memory, the system checks the thresholds for that partition and compacts immediately if any are exceeded.
  2. Scheduled sweep — an hourly background job checks all memory banks with at least one compaction trigger configured. For each bank, every partition (conversation key or group key) is evaluated independently against the thresholds. This ensures entries that cross an age threshold are compacted even when no new writes are occurring.

Both paths are fully automatic — no manual action is required. You can also trigger compaction on-demand from the Configuration tab using the Compact Now button, or via the API (POST /memory_banks/{id}/compact) and MCP (compact_memory_bank_now tool).

How compaction works — when entries are compacted, they are soft-deleted and (if a compaction prompt is configured) summarized into a new entry that preserves the essential information. The summary entry is tagged so it can be distinguished from user-written entries. Compaction is applied per-partition (per conversation key or per group key), so each conversation or group is evaluated independently.

Disabling compaction — to disable a specific threshold, set it to 0 via the API or MCP (max_age_days: 0). In the UI, simply clear the field and save. To disable compaction entirely, clear all three thresholds and optionally clear the compaction prompt.

Testing Compaction

Use the Test Compaction Prompt feature (available on both the create page and the Configuration tab) to preview how a compaction prompt performs before committing to it. The test flow:

  1. Choose a content source — existing entries from the bank, generate synthetic entries from a description, or paste custom entries directly
  2. Click Run Test to execute the compaction summarizer
  3. Review the results: original entries, compacted summary, surviving entries, and a structured quality evaluation scored by an LLM-as-judge

This lets you iterate on the compaction prompt until you are satisfied with the summary quality. Entries configured with custom roles (system, user, assistant) are supported for conversation banks.

AI Assistant

The AI Assistant can suggest configuration changes for your memory bank. Available from both the create page (as Use AI assistant) and the Configuration tab:

  1. Describe what you want the memory bank to do in plain language
  2. The assistant suggests a compaction prompt, thresholds (max age, max size, max turns), and retention
  3. Review the suggestions and apply them with one click

This is useful when you are not sure what compaction prompt or thresholds to use for your use case.

Retention

Retention controls how long entries are kept before automatic deletion. Choose a preset duration (1 week, 1 month, 3 months, 1 year), select Custom and enter any number of days, or choose Indefinite to keep entries forever. Retention is set at creation time and can be updated later from the Configuration tab.

Content Source

Each memory bank has a linked content source (a system-managed source connection). The source is eagerly provisioned when the bank is created — it is available immediately, before any entries are written. Entries are stored as content versions inside this source, embedded and chunked according to the bank's configuration.

The content source is managed from the Configuration tab of the detail page:

  • View Source — Opens the content source detail page where you can browse individual entries
  • Delete Source — Removes all stored entries and resets the bank's data. The source connection is re-provisioned automatically the next time an agent writes to the bank

Using Memory Banks in Agents

Once created, use a memory bank in your agent's steps:

  1. Open the agent editor
  2. Add a Write Memory, Search Memory, or Load Memory step
  3. Select a memory bank from the dropdown (both conversation and general banks are shown)
  4. Configure the key and other fields — for conversation banks, also set the speaker

See Agent Steps → Memory for full details on all memory step types.

API Access

Memory banks can be managed programmatically via the Public API using your API key:

# List memory banks (filter by type with ?type=conversation or ?type=general)
curl "https://api.seclai.com/memory_banks?type=conversation" \
  -H "X-API-Key: $SECLAI_API_KEY"

# List pre-built templates
curl https://api.seclai.com/memory_banks/templates \
  -H "X-API-Key: $SECLAI_API_KEY"

# Create a memory bank (with optional description)
curl -X POST https://api.seclai.com/memory_banks \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "My Memory Bank", "description": "Stores customer context", "type": "conversation", "mode": "balanced"}'

# Get a memory bank
curl https://api.seclai.com/memory_banks/$MEMORY_BANK_ID \
  -H "X-API-Key: $SECLAI_API_KEY"

# Update a memory bank
curl -X PUT https://api.seclai.com/memory_banks/$MEMORY_BANK_ID \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"name": "Renamed Bank", "compaction_prompt": "Summarize concisely"}'

# Delete a memory bank
curl -X DELETE https://api.seclai.com/memory_banks/$MEMORY_BANK_ID \
  -H "X-API-Key: $SECLAI_API_KEY"

# Delete a memory bank's content source (reset data)
curl -X DELETE https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/source \
  -H "X-API-Key: $SECLAI_API_KEY"

# List agents using a memory bank
curl https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/agents \
  -H "X-API-Key: $SECLAI_API_KEY"

# Get entry statistics (last 30 days by default, or specify a range)
curl "https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/stats?days=30" \
  -H "X-API-Key: $SECLAI_API_KEY"

# Test a compaction prompt against an existing bank
curl -X POST https://api.seclai.com/memory_banks/$MEMORY_BANK_ID/test-compaction \
  -H "X-API-Key: $SECLAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"compaction_prompt": "Keep only essential facts."}'

See API Examples → Memory Banks for more examples.

MCP Tools

All memory bank operations are available as MCP tools for AI coding assistants:

ToolDescription
list_memory_bank_templatesList pre-built template configurations for common use cases
list_memory_banksList memory banks with pagination and sorting
get_memory_bankGet full details of a memory bank
create_memory_bankCreate a new memory bank
update_memory_bankUpdate a memory bank's configuration
delete_memory_bankDelete a memory bank
delete_memory_bank_sourceDelete a bank's content source (reset data)
get_agents_using_memory_bankList agents that reference a specific memory bank
get_memory_bank_statsGet aggregated entry statistics for a memory bank
test_compaction_promptTest a compaction prompt with LLM-as-judge evaluation

See MCP Server → Memory Bank Tools for setup instructions.

Exporting

Export a memory bank's entries and configuration as a downloadable JSON file.

  • UI: Open the memory bank detail page and click the Export button. You'll see an estimate of the export size before confirming.
  • API: POST /authenticated/resource-exports with resource_type: "memory_bank" and the memory bank ID.
  • MCP: Use the create_resource_export tool with resource_type: "memory_bank".

See Export Formats → Memory Bank for the full file schema and available filter options.

Next Steps