# Atlaso + LlamaIndex

<!-- Canonical: https://www.atlaso.ai/docs/recipes/llamaindex -->

`pip install atlaso[llamaindex]` is reserved namespace today; full adapter lands based on revealed-intent signals over 60 days post-release. Today, wrap manually:

```python
from atlaso import Memory
from llama_index.core.memory.types import BaseMemory
from llama_index.core.llms import ChatMessage, MessageRole

class AtlasoLlamaMemory(BaseMemory):
    """LlamaIndex BaseMemory backed by Atlaso. Carries dispersion fields in metadata."""

    def __init__(self, user_id: str):
        self._mem = Memory().for_user(user_id)

    def get(self, input: str | None = None, **kwargs) -> list[ChatMessage]:
        if not input:
            recent = self._mem.list_recent(limit=10)
            return [ChatMessage(role=MessageRole.USER, content=d.content) for d in recent]

        results = self._mem.recall(input, limit=10)
        msgs = []
        for r in results:
            # LlamaIndex BaseMemory carries metadata across the boundary —
            # use it to surface the +10pp dispersion fields downstream.
            msgs.append(
                ChatMessage(
                    role=MessageRole.USER,
                    content=r.content,
                    additional_kwargs={
                        "is_confident": r.is_confident,
                        "has_disagreement": r.has_disagreement,
                        "agreement_score": r.agreement_score,
                    },
                )
            )
        return msgs

    def put(self, message: ChatMessage) -> None:
        if message.content:
            self._mem.add(message.content)

    def reset(self) -> None:
        # See langchain.md note — Atlaso deposits are immutable.
        raise NotImplementedError("Use m.retract(deposit_id, reason=...) per row.")
```

**Why LlamaIndex over LangChain for Atlaso:** LlamaIndex's `BaseMemory.get()` returns `ChatMessage` objects with `additional_kwargs`, which lets the dispersion fields ride along. LangChain's `BaseMemory` returns `dict[str, str]` and drops them.

---

<!-- atlaso:doc-trailer -->
**Source:** <https://www.atlaso.ai/docs/recipes/llamaindex>  
**Edit on GitHub:** <https://github.com/imashishkh21/atlaso/tree/main/docs/recipes/llamaindex.md>  
**Updated:** 2026-05-12
