Skip to main content

CrewAI integration for Smara Memory API — persistent memory for AI agents

Project description

smara-crewai

CrewAI integration for the Smara Memory API -- persistent, semantic memory for AI agents.

Install

pip install smara-crewai

Quick start

1. Memory backend (automatic)

Plug SmaraMemory into CrewAI so all agent memory is automatically persisted and retrieved via Smara.

import os
from crewai import Agent, Crew, Task
from smara_crewai import SmaraMemory

os.environ["SMARA_API_KEY"] = "smara_..."

crew = Crew(
    agents=[
        Agent(
            role="Researcher",
            goal="Find and remember key facts",
            backstory="You are a diligent research assistant.",
        )
    ],
    tasks=[
        Task(
            description="Research the latest AI memory techniques.",
            expected_output="A summary of techniques.",
        )
    ],
    memory=True,
    memory_config={
        "provider": SmaraMemory(user_id="research-session"),
    },
)

crew.kickoff()

Every memory created during the run is stored in Smara. On the next run (even from a different machine), the same memories are available.

2. Agent tools (explicit)

Give agents SmaraStoreTool and SmaraSearchTool so they can decide when to remember or recall information.

from crewai import Agent
from smara_crewai import SmaraStoreTool, SmaraSearchTool

store = SmaraStoreTool(user_id="customer-support")
search = SmaraSearchTool(user_id="customer-support")

agent = Agent(
    role="Support Agent",
    goal="Help customers and remember their preferences",
    backstory="You are a helpful support agent with long-term memory.",
    tools=[store, search],
)

The agent will autonomously call smara_store_memory when it learns something important and smara_search_memory when it needs past context.

3. Direct client usage

from smara_crewai.client import SmaraClient

client = SmaraClient(api_key="smara_...")

# Store
client.store(user_id="u1", fact="User prefers dark mode", importance=0.7)

# Search
results = client.search(user_id="u1", query="UI preferences")
for mem in results:
    print(mem["fact"], mem.get("score"))

# User context
ctx = client.get_context(user_id="u1")
print(ctx)

Configuration

Parameter Env var Default
api_key SMARA_API_KEY (required)
base_url SMARA_API_URL https://api.smara.io
user_id -- "default"

API reference

SmaraMemory (Storage backend)

  • save(value, metadata=None) -- store a memory (called automatically by CrewAI)
  • search(query, limit=5, score_threshold=0.0) -- retrieve relevant memories

SmaraStoreTool

Agent tool to store a memory. Accepts fact (str) and importance (float 0-1).

SmaraSearchTool

Agent tool to search memories. Accepts query (str) and limit (int 1-50).

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

smara_crewai-0.1.0.tar.gz (5.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

smara_crewai-0.1.0-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file smara_crewai-0.1.0.tar.gz.

File metadata

  • Download URL: smara_crewai-0.1.0.tar.gz
  • Upload date:
  • Size: 5.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for smara_crewai-0.1.0.tar.gz
Algorithm Hash digest
SHA256 fc61342e83a191a125b65e01f523f8d389994b3fec022d550fc974cb294deae1
MD5 45b1956e443e70249ecc60e83280029c
BLAKE2b-256 22994e5d84f5aed97f97f38c7d0e688487ddbddc612743c723051c6db774b832

See more details on using hashes here.

File details

Details for the file smara_crewai-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: smara_crewai-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for smara_crewai-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 479194f2cf0853937c5910b2d01fc9a09af6f85517c672892e56000065750169
MD5 67fc3babea920f642f45d8b8ed9ac9ea
BLAKE2b-256 c66ee78724b0183a6f10e1f1ea05d771ccb3f97231aa2116dd34003fb6b0fe64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page