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

# CrewAI

> Give your CrewAI agents persistent memory with procedural learning.

The [`mengram-crewai`](https://pypi.org/project/mengram-crewai/) package wires Mengram memory into any CrewAI agent as tools.

## Installation

```bash theme={null}
pip install mengram-crewai
```

## Quick start

```python theme={null}
from mengram_crewai import mengram_tools
from crewai import Agent, Task, Crew

tools = mengram_tools(api_key="om-your-key", user_id="user-123")

agent = Agent(
    role="Support Engineer",
    goal="Help users with technical issues using past context",
    backstory="You remember every prior interaction and learned workflow.",
    tools=tools,
)

task = Task(
    description="Help the user debug their deployment issue",
    expected_output="A resolution grounded in the user's history",
    agent=agent,
)

result = Crew(agents=[agent], tasks=[task]).kickoff()
```

`api_key` falls back to `MENGRAM_API_KEY` and `user_id` to `MENGRAM_USER_ID` if omitted.

## Available tools

`mengram_tools()` returns three tools ready to pass to `Agent(tools=...)`:

| Tool | Description |
| - | - |
| `search_memory` | Semantic search over facts, preferences, and past events |
| `save_memory` | Save a durable fact or decision to long-term memory |
| `get_procedures` | Retrieve learned workflows — steps, success/failure record, and preconditions to verify |

## Procedural learning

`get_procedures` is the distinctive tool. When a workflow has failed before, Mengram returns it with the preconditions that were violated last time, so the agent verifies them up front instead of repeating the mistake.

```python theme={null}
tools = mengram_tools(api_key="om-...", user_id="user-123")
# The agent calls get_procedures("deploy to Railway") and receives, e.g.:
#   deploy-railway (v3, 11 ok / 1 failed) — verify first: run migrations before push
```

## Options

```python theme={null}
mengram_tools(
    api_key="om-...",       # or MENGRAM_API_KEY
    user_id="user-123",     # or MENGRAM_USER_ID; multi-user isolation
    limit=5,                # max results per search/procedures call
    base_url="https://...", # self-hosted instances
)
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.