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

# Memory

> What an agent remembers as the conversation grows — three variants, three scenarios.

Memory examples enact the trade-off between recall, cost, and latency. Sources under [`examples/memory/`](https://github.com/0xvasanth/cognis/tree/main/examples/memory).

| Name                     | Scenario                                                                                                                                           | Source                                                                                         |
| ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `memory_types`           | Run the same 5-turn conversation through `Buffer`, `Window(2)`, and `TokenBufferMemory(200)` — watch which ones still pass the recall test.        | [src](https://github.com/0xvasanth/cognis/blob/main/examples/memory/memory_types.rs)           |
| `memory_summary_buffer`  | 10-turn customer support thread — older turns get LLM-summarized into a running summary so the agent can still recall the original order ID.       | [src](https://github.com/0xvasanth/cognis/blob/main/examples/memory/summary_buffer_memory.rs)  |
| `memory_knowledge_graph` | Bot learns facts about Project Atlas through conversation, then is asked to recall them — the KG memory stores triples and the agent queries them. | [src](https://github.com/0xvasanth/cognis/blob/main/examples/memory/knowledge_graph_memory.rs) |

## How to run

```bash theme={null}
COGNIS_PROVIDER=ollama COGNIS_OLLAMA_MODEL=llama3.1 \
  cargo run -p cognis-examples --example memory_types
```

## Pick a starting point

* **First time?** `memory_types` shows all three variants on the same conversation, side by side.
* **Long sessions?** `memory_summary_buffer` is the right default — buffer keeps recent turns, summary keeps the long-tail facts.
* **Knowledge-graph use cases?** `memory_knowledge_graph` for triple-shaped memory across sessions.

## See also

<CardGroup cols={2}>
  <Card title="Memory guide" icon="brain" href="/building-agents/memory">
    All variants explained, when to reach for each.
  </Card>

  <Card title="Patterns → Stateful chat" icon="grid" href="/patterns/stateful-chat">
    Memory + persistence in a real chat backend.
  </Card>
</CardGroup>
