# Memory and knowledge

> How PentAGI remembers commands, results and relationships across a flow.

PentAGI keeps three kinds of [memory](https://pentagi.com/docs/glossary/#memory) so [agents](https://pentagi.com/docs/glossary/#agent) can build on earlier work instead of starting from scratch.

| Memory    | Where it lives                       | What it holds                                                                           |
| --------- | ------------------------------------ | --------------------------------------------------------------------------------------- |
| Long-term | PostgreSQL with pgvector             | Embeddings of results, successful approaches and [tool](https://pentagi.com/docs/glossary/#tool) knowledge |
| Working   | [Flow](https://pentagi.com/docs/glossary/#flow) context | The current goal, [task](https://pentagi.com/docs/glossary/#task) state and available resources            |
| Episodic  | Command history                      | Past actions, their outcomes and patterns that worked                                   |

Every command and its output is stored in PostgreSQL. Agents query the [vector store](https://pentagi.com/docs/glossary/#vector-store) for similar cases before acting, and write their [findings](https://pentagi.com/docs/glossary/#finding) back — the `memorist` and `searcher` agents do most of this lookup work.

## [Knowledge graph (optional)](https://pentagi.com/docs/concepts/memory/#knowledge-graph-optional)

With the [knowledge graph](https://pentagi.com/docs/glossary/#knowledge-graph) stack enabled, PentAGI sends agent responses and tool executions to [Graphiti](https://github.com/getzep/graphiti) on Neo4j. With the ingest rules of the `.env` template, it extracts entities and relationships — hosts, services, vulnerabilities, techniques and how they relate over time — from terminal and file operations, and keeps the other events searchable without extraction.

```bash
GRAPHITI_ENABLED=true
GRAPHITI_URL=http://graphiti:8000
GRAPHITI_CONFIG_DIR=llm_configs
GRAPHITI_LLM_CLIENT_TYPE=openai
NEO4J_URI=bolt://neo4j:7687
NEO4J_PASSWORD=replace_with_a_strong_password
```

```bash
git clone --depth 1 https://github.com/vxcontrol/pentagi.git pentagi-src
cp -r pentagi-src/examples/graphiti ./graphiti
cp -r pentagi-src/examples/neo4j ./neo4j
rm -rf pentagi-src
curl -O https://raw.githubusercontent.com/vxcontrol/pentagi/main/docker-compose-graphiti.yml
docker compose -f docker-compose.yml -f docker-compose-graphiti.yml up -d
```

Graphiti runs its own model: `GRAPHITI_LLM_CLIENT_TYPE` picks the preset — `openai`, `gemini`, `litellm` or `custom` — whose models are set in `./graphiti/<preset>.yaml`, and the matching key comes from `.env` (`OPEN_AI_KEY` for `openai`). An `.env` from before 2.2.0 lacks these lines and the `GRAPHITI_INGEST_*` rules: copy them from the current `.env.example`.

> [!WARNING]
> Graphiti is a beta integration and is off by default. Recall is scoped to the active flow; the bundled Graphiti API has no authentication, so keep it and Neo4j on a private network. Extraction and embeddings are billed separately from the flow's own model.

PentAGI checks Graphiti only when it starts, for a few seconds. If Graphiti is not ready by then, PentAGI logs a warning and runs without the knowledge graph until its next restart, so once Graphiti reports healthy, run `docker restart pentagi`.