Skip to content

Memory & context

Agents need memory to hold a coherent conversation. Alquimia Platform provides two memory layers: short-term memory controls what the LLM sees right now, and long-term memory decides what to keep when conversations grow too large.

Short-term memory limits which messages from the conversation history are included in the LLM prompt. Without a strategy, the full history is sent, which can exceed the model’s context window or dilute attention.

The default strategy walks backward through the conversation and keeps messages until a token budget is reached. You can also filter which interactions to include based on runtime conditions.

Long-term memory strategies trigger when the conversation crosses a threshold — for example, after a number of turns or a token count. When triggered, the strategy either summarizes or erases older history.

The summarizer compresses old conversation turns into a dense summary. The summary is kept in the conversation context and can optionally be stored in a vector store for later retrieval. This preserves the gist of long conversations without consuming the full context window.

The erasure strategy simply drops older interactions beyond a configured keep count. It is faster and cheaper than summarization, but loses historical detail. Use it when the recent turns are all that matter.

Strategies can keep history by whole human-assistant interactions or by individual tool round trips. Step-level control is useful for long agentic runs where a single human message triggers many tool calls; interaction-level control is simpler for ordinary chat.

After an inference run, the conversation is persisted according to a strategy:

StrategyBehavior
INCREMENTALAppend new messages to the existing session (default)
FLUSHReplace the session with the current conversation
EPHEMERALDo not persist — the session is lost after inference

FLUSH is useful when you want each turn to start from a clean slate while still preserving history on block events.

In addition to conversation history, agents can retrieve context from knowledge bases. Depending on the search mode, knowledge can be:

  • Injected automatically into every prompt (rag).
  • Exposed as a search tool the agent invokes (on_demand).
  • Accessed as files the agent reads (direct).
  • Queried from a Boltzmann Brain with fine-grained authorization (brain).

The vector-store backend is selected at deployment time, not baked into individual topics. This lets the same agent run against Qdrant, Redis, or an in-memory store depending on the environment.

Good memory management is what makes an agent useful across multiple turns instead of just a single question-answer exchange. It also controls cost and latency: every token kept in context is billed, and overly long prompts slow down responses.