Get started
The agent loop
The one call per turn that stores what was said and returns what is relevant.
MenteDB gives your agent long-term memory through one call: process_turn. Each turn it stores what was said, retrieves what is relevant, and hands back the memories to put in your next prompt. That loop is the whole integration.
each turn:
1. build your prompt with the memories from last turn's context
2. call your LLM, get a reply
3. process_turn(user_message, reply) -> returns context for next turnprocess_turn embeds the user message, runs hybrid recall (vector + keyword + graph) over everything stored so far, saves the new turn, and returns the relevant memories as context. On the first turn context is empty because nothing has been learned yet. By turn two it carries the facts, preferences, and corrections from earlier in the conversation, and across sessions.
Fact extraction and contradiction detection need an LLM. On cloud that is wired up for you. When self-hosting you set MENTEDB_LLM_PROVIDER and MENTEDB_LLM_API_KEY; without them you still get storage and recall, just no automatic extraction. There is no configure_llm() call, it is environment or platform config.
Which example do I want?
Pick the cell that matches where MenteDB runs and your language. Cloud talks to https://api.mentedb.com over REST with an mdb_ API key, no SDK to install and nothing to run. Self-hosting embeds the engine in your process with data on local disk, you own the LLM key and the maintenance schedule.
| Python | Node / TypeScript | Rust | |
|---|---|---|---|
| Cloudmanaged, no infra | REST + requests | REST + fetch | REST |
| Self-hostedembedded, your disk | pip install mentedb | npm install mentedb | cargo add mentedb |
What process_turn returns
One call runs the full cognitive pipeline and returns everything it found. The field you use most is context. The rest is signal you can act on or ignore.
| Field | What it is |
|---|---|
| context | Memories relevant to this turn, attention-ordered. Prepend to your next prompt. |
| facts_extracted | Facts learned this turn. Zero without an LLM configured. |
| contradiction_count | New information that conflicts with an existing belief. |
| pain_warnings | Things that went wrong in similar past contexts. |
| stored_ids | Memory IDs written this turn. |
| predicted_topics | Where the conversation is likely heading, from trajectory analysis. |
Node returns these in camelCase (factsExtracted, contradictionCount); Python and the REST payload use snake_case.