MemoryMesh Python SDK
MemoryMesh gives AI agents durable work memory: the decisions they made, the tools they used, the evidence they found, the checkpoints they can resume from, and the final receipt a human can inspect.
Use this SDK when a Python worker, notebook, backend service, or agent framework needs to talk to a MemoryMesh API deployment.
What You Can Build
- Run a built-in MemoryMesh agent and receive an inspectable receipt.
- Store and recall Cognee-backed memory across sessions.
- Record tool traces, validations, checkpoints, and recovery state.
- Wrap custom Python tools so every important action is auditable.
- Support three memory modes: local Cognee, Cognee Cloud, and offline mirror/demo mode.
Install
pip install memorymesh-sdk
The SDK is dependency-free by default. It uses Python's standard HTTP libraries and works with Python 3.10+.
Choose a Memory Mode
| Mode | Backend value | Best for |
|---|---|---|
| Local/self-hosted Cognee | local_cognee |
Private developer machines, self-hosted teams, regulated environments. |
| Cognee Cloud | cognee_cloud |
Managed memory with minimal infrastructure work. |
| Demo/offline mirror | offline_mirror |
Demos, tests, and fallback when Cognee is unavailable. |
Connect to MemoryMesh
import os
from memorymesh import MemoryMeshClient
client = MemoryMeshClient(
base_url=os.environ.get("MEMORYMESH_API_URL", "https://api-two-blue-75.vercel.app"),
api_key=os.environ.get("MEMORYMESH_API_KEY"),
default_memory_backend="cognee_cloud",
)
For a signed user session or a gateway that expects bearer auth:
client = MemoryMeshClient(
base_url="https://your-memorymesh-api.example.com",
api_key=os.environ["MEMORYMESH_SESSION_TOKEN"],
api_key_header="Authorization",
)
For an API-key deployment, keep the default X-MemoryMesh-API-Key header:
client = MemoryMeshClient(
base_url="https://your-memorymesh-api.example.com",
api_key=os.environ["MEMORYMESH_API_KEY"],
)
Verify the Runtime
print(client.health())
print(client.memory_status("cognee_cloud", probe=True))
If Cognee Cloud is configured, memory_status should report ready: true. If fallback is enabled, offline_mirror remains available for demos and tests.
Run an Agent and Inspect the Receipt
receipt = client.run_agent(
agent_id="research",
task="Compare durable memory options for coding agents.",
backend="cognee_cloud",
)
print(receipt["run_id"])
print(receipt["status"])
print(receipt["final_output"])
print(receipt["receipt_ref"])
for source in receipt.get("evidence", []):
print(source)
for op in receipt.get("memory_operations", []):
print(op.get("operation"), op.get("backend"), op.get("status"))
Agent ids currently used by the reference runtime:
| Agent | Purpose |
|---|---|
build |
Code/project work with checkpoints, test traces, and handoff receipts. |
research |
Source-backed investigation with memory and reusable findings. |
support |
Ticket/support investigation with tool traces and recovery state. |
The response is both a flat receipt and, on newer APIs, includes receipt and receipt_ref for clients that prefer an explicit receipt envelope.
Remember, Recall, Improve, Forget
session_id = "pricing-research-2026-07"
client.remember(
text="The research agent found that pricing pages changed after the July launch.",
dataset="gtm-intelligence",
session_id=session_id,
metadata={"source": "pricing_monitor", "confidence": 0.86},
)
matches = client.recall(
query="What changed on pricing pages?",
dataset="gtm-intelligence",
session_id=session_id,
top_k=3,
)
client.improve_memory(
feedback="Future GTM research should compare pricing claims against saved baseline evidence.",
dataset="gtm-intelligence",
session_id=session_id,
)
# Use carefully in production.
client.forget_memory(dataset="gtm-intelligence", session_id=session_id)
Tool Tracing and Checkpoints
Wrap any Python function used by an agent. MemoryMesh records the input, output, validation signals, and an optional checkpoint.
from memorymesh import MemoryMeshClient, ToolWrapperConfig, trace_tool
client = MemoryMeshClient("http://localhost:8000")
run = client.start_run(
agent_id="support-agent",
task="Investigate payment failures.",
)
@trace_tool(
client,
run["task_id"],
ToolWrapperConfig(
tool_name="fetch_tickets",
tool_type="read",
checkpoint_after=True,
validation=lambda args, kwargs, result: {"records": len(result)},
observed_signals=lambda args, kwargs, result: {"has_high_priority": any(t["priority"] == "high" for t in result)},
),
)
def fetch_tickets(status: str):
return [{"id": "ticket_1", "status": status, "priority": "high"}]
tickets = fetch_tickets("open")
For external actions such as sending email, filing a ticket, or changing infrastructure, pass a stable idempotency_key so the server can prevent duplicate side effects.
Recover a Run
checkpoint = client.save_checkpoint(
task_id=run["task_id"],
checkpoint_name="after_ticket_fetch",
state={"ticket_count": len(tickets)},
resume_state={"current_step": "summarise_tickets"},
)
restored = client.restore_checkpoint(checkpoint["checkpoint_id"])
print(restored)
Framework Adapters
The package also exports adapters for common agent runtimes:
from memorymesh import (
MemoryMeshCrewAIAdapter,
MemoryMeshLangGraphAdapter,
MemoryMeshCheckpointer,
MemoryMeshOpenAIAgentsMiddleware,
)
Use the framework adapters when you already have an agent runtime. Use trace_tool when you want the smallest dependency-free integration.
Error Handling
from memorymesh import MemoryMeshError
try:
client.memory_status("cognee_cloud", probe=True)
except MemoryMeshError as error:
print("status:", error.status)
print("detail:", error.detail or error.body)
Production Checklist
- Set
MEMORYMESH_API_URLto your deployed API. - Use
Authorizationfor signed user sessions orX-MemoryMesh-API-Keyfor API-key deployments. - Pick the memory backend intentionally:
local_cognee,cognee_cloud, oroffline_mirror. - Store evidence and source URLs in metadata so receipts are auditable.
- Use checkpoints before long or risky tool sequences.
- Use idempotency keys for write/external actions.
- Call
forget_memoryfor temporary, sensitive, or stale sessions.
Troubleshooting
| Symptom | What to check |
|---|---|
401 |
Use the correct header: Authorization for session tokens, X-MemoryMesh-API-Key for API keys. |
| Cognee status not ready | Check COGNEE_SERVICE_URL, COGNEE_API_KEY, and whether fallback is enabled. |
| Empty recall results | Use the same dataset, session_id, and backend used by remember. |
| Duplicate external action | Add a stable idempotency key to action/tool execution. |
| Receipt is missing expected evidence | Ensure tools are wrapped or evidence is passed into memory metadata. |
Links
- Repository: https://github.com/othnielObasi/memorymesh
- Documentation: https://github.com/othnielObasi/memorymesh/tree/main/docs
- Live API used in examples: https://api-two-blue-75.vercel.app
Metadata
Release files for memorymesh-sdk 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| memorymesh_sdk-0.1.1.tar.gz | 14.0 kB | Without provenance | Details for memorymesh_sdk-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| memorymesh_sdk-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for memorymesh_sdk-0.1.1-py3-none-any.whl |
Total release size: 27.4 kB
Release files / memorymesh_sdk-0.1.1.tar.gz
| Download URL | memorymesh_sdk-0.1.1.tar.gz |
|---|---|
| Size | 14.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
68acc6b791a03b7fb8e9d31c6b63ec8b1a613a14a40bd99399ede9b7ffc6bfae
|
|
BLAKE2b-256 checksum How to use checksums |
5f371261cf060acc1f90d5be6c4a15dac6733c9e2e0f90257c13d461acfa02af
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Release files / memorymesh_sdk-0.1.1-py3-none-any.whl
| Download URL | memorymesh_sdk-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.5 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
6e392061ba3c769f730f5456989eb5df981fec107a418cf20d890632640126a3
|
|
BLAKE2b-256 checksum How to use checksums |
862524a2312674b282afc0326cc6cdecac7e77958ebee270930341ec40ed2a3b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.10
|
Security for memorymesh-sdk 0.1.1
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.