Skip to main content

recallic-pydantic-ai: Recallic memory for Pydantic AI

Website: recallic.com

Long-term memory for Pydantic AI agents, backed by a self-hosted Recallic server. It is a Pydantic AI capability.

  • No LLM calls for memory. Storing and searching use Recallic's local models.
  • Across runs and conversations. Each run, what this user said before that bears on their prompt is recalled, whatever conversation it was said in.
  • Honest. When nothing answers it, the model is told there is no record instead of being handed near-misses to guess from.
  • Your data stays on your server, separated per user and per agent.

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

Install

pip install recallic-pydantic-ai

Run Recallic (quickstart) and create a key with role service, which acts for each of your users (or use a user's own key and leave the user out):

python -m backend.tools.keys create --user my-pydantic-app --role service

Automatic memory: RecallicMemory

import os

from pydantic_ai import Agent
from recallic_pydantic_ai import RecallicMemory

memory = RecallicMemory(os.environ["RECALLIC_SERVICE_KEY"], base_url="http://localhost:8000",
                        mode="balanced")                           # or "cautious" / "helpful"
agent = Agent("openai:gpt-5-mini", instructions="You are a helpful assistant.", deps_type=str,
              capabilities=[memory])

agent.run_sync("I moved to Pune in March.", deps="alice")

# days later, a new conversation
print(agent.run_sync("Which city did I move to?", deps="alice").output)   # "Pune."

At the start of each run the capability recalls on the user's prompt. It puts the memories in front of the model, just before the prompt, as a <user_memories> block marked as written by the user. Your own instructions are kept. Each memory is dated, with a note that a fact stays true until a later memory changes it. When Recallic declines but found memories, they are given with a note that Recallic is not sure they answer; when it finds nothing, it adds a short instruction telling the model there is no record. Then it stores the prompt. Recall runs once per run, not once per model request in a tool loop.

Whose memory. The user comes from the run's deps: a string is the user id, otherwise deps["user_id"] or deps.user_id. When the deps name no user, the user_id field is used. With neither, a service key falls back to the key's own user, which every run would then share. So with a service key, always name the user.

Parameter Default What it does
api_key RECALLIC_API_KEY env var A Recallic key. service acts for each user; a user key acts for itself.
base_url http://localhost:8000 Your Recallic server.
user_id None The user when the run's deps name none.
agent_id pydantic-ai Recallic agent id; each agent reads back what it wrote (and what any agent shared).
mode server's recall.mode cautious reads with a stricter reader and declines more (more "I don't know"); helpful answers more counting, ordering and "how long between" questions.
limit 5 Memories given to the model per run.
store_user_messages True Store the user's prompt each run (after recalling).
tell_model_on_decline True When Recallic finds no memory at all, tell the model not to guess about the user's past.
keep_on_decline True When Recallic declines but found memories, still give them to the model, with a note that Recallic is not sure they answer the message. False: a decline gives the no-record note only. recallic_toolset() takes it too.
tools False Also give the model recall_memory(query) and save_memory(fact) tools.

RecallicMemory has the default id recallic_memory. It also loads from an agent spec: Agent.from_spec(spec, custom_capability_types=[RecallicMemory]), with - RecallicMemory: {mode: cautious} in YAML and the key in RECALLIC_API_KEY.

Tools only: recallic_toolset()

When the agent should decide itself when to look things up or save them:

from recallic_pydantic_ai import recallic_toolset

tools = recallic_toolset(os.environ["RECALLIC_SERVICE_KEY"])   # recall_memory(query), save_memory(fact)
agent = Agent("openai:gpt-5-mini", deps_type=str, toolsets=[tools])
agent.run_sync("What's my sister's name?", deps="alice")

The tools read the user from the run's deps in the same way.

Notes:

  • The memories and the no-record note are capability parts (RecalledMemoriesPart, NoRecordPart), so they are kept in the run's message history and you can find them by type.
  • format_memories(recall_result) turns any Recallic recall result into plain text, as the recall_memory tool returns it.
  • Only the user's prompts are stored, not the model's replies.
  • Needs Recallic server 0.2.5 or newer. Tested with pydantic-ai-slim 2.77.0.

Tests

Against a running Recallic: RECALLIC_URL=http://127.0.0.1:8000 RECALLIC_SERVICE_KEY=rx_... pytest tests. They run a real Agent with a scripted FunctionModel, including its tool loop, and one with TestModel.

Licence: Apache-2.0.

Metadata

Release files for recallic-pydantic-ai 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for recallic-pydantic-ai 0.1.2
File Size Uploaded Provenance Actions
recallic_pydantic_ai-0.1.2.tar.gz 12.8 kB Without provenance Details for recallic_pydantic_ai-0.1.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for recallic-pydantic-ai 0.1.2
File Interpreter ABI Platform Actions
recallic_pydantic_ai-0.1.2-py3-none-any.whl Python 3 none any Details for recallic_pydantic_ai-0.1.2-py3-none-any.whl

Total release size: 24.4 kB

Release files / recallic_pydantic_ai-0.1.2.tar.gz

Download URL recallic_pydantic_ai-0.1.2.tar.gz
Size 12.8 kB
Tags Source
SHA-256 checksum
How to use checksums
c2f124269a0991f6afb0c053763f0c0a7a504548b3d3b6aefd02b0f09a025caf
BLAKE2b-256 checksum
How to use checksums
2eeac404677f2c80a3230fa61ed0a64ff233cca97b95bb4a1ce0e98ffad2aa80
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Release files / recallic_pydantic_ai-0.1.2-py3-none-any.whl

Download URL recallic_pydantic_ai-0.1.2-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6737056231031fb197bb9b6f7f6ad6b4342c13371e55fa6e79078d79d93aa116
BLAKE2b-256 checksum
How to use checksums
2bcb496837147af8760505d9017da28dca6b46b8d48e3d195253247556e0d474
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.10

Security for recallic-pydantic-ai 0.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page