> For the complete documentation index, see [llms.txt](https://yeagerai.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://yeagerai.gitbook.io/docs/modules/memory.md).

# Memory

Memory in YeagerAI plays a crucial role in maintaining context and storing information generated by AI agents. It is designed to be scalable and efficient, ensuring that your AI agents have access to the information they need when they need it.

YeagerAI uses a `YeagerAIContext` class to manage the memory of an agent. It is responsible for loading and saving session message history and creating "shadow clones" to facilitate memory management.

```python
from yeagerai.memory import YeagerAIContext

context_memory = YeagerAIContext(username="John Doe", session_id="example_session", session_path="path/to/sessions")
context_memory.load_session_message_history()
```

The `KageBunshinNoJutsu` class serves as a callback handler to manage safe loading and memory tasks. It initializes with a `YeagerAIContext` instance and handles various events, such as agent finish, LLM (Language Model) end, and chain end, to ensure proper memory management throughout the agent's lifecycle.

```python
from yeagerai.memory import KageBunshinNoJutsu

kage_bunshin = KageBunshinNoJutsu(context_memory=context_memory)
```

In summary, YeagerAI's memory management system ensures that your AI agents have a reliable and efficient way to store and retrieve information, facilitating learning and improvement over time.
