Metadata-Version: 2.5
Name: crewai-recallic
Version: 0.1.0
Summary: Recallic memory tools for CrewAI agents: self-hosted, no LLM calls for memory, says when it has no record.
Project-URL: Homepage, https://www.recallic.com
Project-URL: Source, https://github.com/Recallic/Recallic/tree/main/integrations/crewai
License-Expression: Apache-2.0
License-File: LICENSE
Requires-Python: <3.14,>=3.10
Requires-Dist: crewai>=1.0
Requires-Dist: recallic>=0.3.0
Description-Content-Type: text/markdown

# crewai-recallic: Recallic memory tools for CrewAI

Website: [recallic.com](https://www.recallic.com)

Long-term memory for [CrewAI](https://www.crewai.com) agents, backed by a self-hosted
[Recallic](https://github.com/Recallic/Recallic) server. It gives an agent two tools: one to look up what a user told
it before, and one to save what the user tells it now.

* **No LLM calls for memory.** Storing and searching use Recallic's local models.
* **Across crews and runs.** A fact saved in one crew run can be recalled in any later run with the same user.
* **Honest.** When no stored memory answers the question, the tool tells the agent there is no record and not to
  guess, instead of handing it near-misses.
* **Your data stays on your server**, separated per user and per agent.

This integration is Apache-2.0. The Recallic server is source-available.

## Install

```bash
pip install crewai-recallic
```

Run Recallic ([quickstart](../../docs/quickstart.md)) and create a key with role `service`, which acts for each of
your users (or use a user's own key and leave `user_id` out):

```bash
python -m backend.tools.keys create --user my-crewai-app --role service
```

## Usage

```python
import os

from crewai import Agent, Crew, Task
from crewai_recallic import recallic_tools

tools = recallic_tools(api_key=os.environ["RECALLIC_SERVICE_KEY"], user_id="alice",
                       base_url="http://localhost:8000")        # recall_memory(query), save_memory(fact)

assistant = Agent(
    role="Personal assistant",
    goal="Help Alice, using what she told you before",
    backstory="Before answering anything about Alice's life, look it up with recall_memory. "
              "When she tells you something about herself, save it with save_memory.",
    tools=tools,
    llm="openai/gpt-5-mini",
)

task = Task(description="Alice says: {message}", expected_output="A short, friendly reply.", agent=assistant)
crew = Crew(agents=[assistant], tasks=[task])

crew.kickoff(inputs={"message": "I moved to Pune in March."})
crew.kickoff(inputs={"message": "Which city did I move to?"})       # "Pune."
crew.kickoff(inputs={"message": "What is my brother's name?"})      # says it has no record
```

You can also make the tools one at a time:

```python
from crewai_recallic import RecallicRecallTool, RecallicSaveTool

recall = RecallicRecallTool(api_key=key, user_id="alice", mode="cautious")
save = RecallicSaveTool(api_key=key, user_id="alice", memory_type="shared")
print(recall.run(query="Where do I work?"))
```

| Parameter | Default | What it does |
|---|---|---|
| `api_key` | required | A Recallic key. Role `service` acts for the `user_id` you pass; a user key acts for itself. |
| `user_id` | `None` | Whose memory the tools read and write. Leave out with a user key. |
| `base_url` | `http://localhost:8000` | Your Recallic server. |
| `agent_id` | `crewai` | Recallic agent id; each agent reads back what it wrote (and what any agent shared). |
| `mode` | server's `recall.mode` | Recall only. `cautious` declines more (more "I don't know"); `helpful` answers more counting, ordering and "how long between" questions. |
| `limit` | 5 | Recall only. Memories given to the agent per lookup. |
| `memory_type` | `private` | Save only (`RecallicSaveTool`). `shared` makes the fact readable by all of the user's agents. |
| `timeout` | 30 | Seconds per request to Recallic. |

## Notes

* **One user per tool instance.** CrewAI does not pass per-run context (such as the current user) to a tool, so the
  user is fixed when the tool is made. In an app with many users, make the tools for each request:
  `recallic_tools(api_key=key, user_id=request_user)`, and build the agent and crew with them.
* **Why tools and not CrewAI's memory setting.** CrewAI's built-in memory hands its storage records it has already
  embedded and scoped with its own LLM. Recallic does the storing, matching and the "does anything answer this?"
  check itself without an LLM, so it fits as tools the agent calls.
* What the agent gets back from `recall_memory` is the memories, newest facts first (with the date each was said),
  or a note that there is no record. `format_memories(recall_result)` gives the same text for any Recallic recall
  result.
* Tool results are not cached by CrewAI, because memory changes during a run. Pass `cache_function=` to change that.
* Needs Recallic server 0.2.5 or newer. Tested with crewai 1.15.

## Tests

Against a running Recallic: `RECALLIC_URL=http://127.0.0.1:8000 RECALLIC_SERVICE_KEY=rx_... pytest tests`.
They include real CrewAI `Agent`/`Task`/`Crew` runs with a scripted LLM.

Licence: Apache-2.0.
