> ## Documentation Index
> Fetch the complete documentation index at: https://agentheya.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory and context management

> What your agent remembers and works from each turn — conversation history, long-term memory per user, knowledge retrieval, and automatic handling of very long conversations.

Each turn, your agent works from several sources: the current conversation, its
long-term memory of the user, and your knowledge base. This page describes what
your agent remembers, how it's kept separate per user, and how long
conversations are handled.

## What your agent works from

| Source               | Lifetime                 | What it is                                 |
| -------------------- | ------------------------ | ------------------------------------------ |
| Conversation history | The current conversation | The back-and-forth so far                  |
| Long-term memory     | Until erased             | What the agent has learned about this user |
| Knowledge retrieval  | Until re-ingested        | Your knowledge base, searched each turn    |

Every conversation is retained in full, so nothing is lost even when a
channel only carries recent messages on the wire. Instant-messaging threads
carry their full history; web and widget chats carry a recent window and rely
on the retained transcript for the rest.

## Long-term memory

Your agent builds up memory about each user over time. The controls live on the
[Memory page](/sidebar-menu/memory), and the full guide is
[User memory](/user-memory). In brief:

* **Two kinds of memory** — freeform notes about what happened, and a
  structured profile of durable facts.
* **Confidence.** Memories carry a confidence level. Things the user stated
  directly count for more than things the agent merely inferred, and
  low-confidence, stale notes fall away over time.
* **Conflicts are flagged.** When a new memory contradicts an existing one, the
  agent surfaces it with a caveat instead of asserting it, until you resolve it
  from the memory page.
* **Learned automatically.** After a conversation, the agent quietly distills
  what's worth remembering, without slowing down the reply.
* **Separated per user.** Each way a user reaches your agent — dashboard login,
  API key, IM sender, email sender, contact — has its own private memory. What
  the agent learns about one user never bleeds into another.
* **Owners can't read a subscriber's contacts' memory.** When a subscriber runs
  their own public instance, their visitors' memories are kept private from the
  owner — a real privacy boundary, not just a hidden view.

## Knowledge retrieval

Each turn, your agent searches your knowledge base for relevant passages and
uses the best matches in its answer. You control how strict retrieval is — a
relevance floor and optional reranking — from the
[knowledge controls](/sidebar-menu/retrieval-test), and you can see exactly
what was searched and used in each turn's activity detail. To try a query
interactively, use the [Retrieval Test page](/sidebar-menu/retrieval-test).

## Long conversations keep working

A very long conversation doesn't fail — as a thread grows, your agent
automatically condenses the older part into a summary and keeps the recent
messages in full, preserving the important details (the user's preferences and
constraints, decisions, open tasks, and concrete facts). This happens on its
own, and any cost is shown in that turn's cost breakdown.

If a single message is genuinely too large to process, your agent returns a
clear "input too large" error rather than silently dropping content.

## Memory is screened

Because remembered facts come back on every future turn, anything your agent is
about to remember is screened for hidden instructions first. A flagged item is
dropped rather than stored, so a poisoned document can't plant an instruction
that re-injects itself later. See [Safety and isolation](/runtime/safety).
