NeuralSnapNeuralSnap/Docs

CrewAI Integration

Give your CrewAI agents persistent, semantically searchable memory that survives across crew runs. Conversations are automatically crystallized into Neural Snapshots — structured knowledge atoms with context, evidence, and connections.

Instead of each crew run starting from zero, agents recall what they learned last time and build on it.

Installation

bash
pip install neuralsnap-crewai

Quick Start

python
from neuralsnap_crewai import NeuralSnapCrewMemory
# Initialize memory
memory = NeuralSnapCrewMemory(
api_key="ns_your_api_key",
brain_id="brain_abc123", # optional — scope to a specific brain
auto_store=True, # auto-crystallize significant interactions
auto_recall=True, # auto-search for context before tasks
store_interval=5, # crystallize every 5 interactions
recall_limit=5, # return top 5 context items
)
# Save a crew interaction
await memory.save(
role="researcher",
content="PostgreSQL outperforms MySQL 3x for our analytical workload",
)
# Search for relevant context
results = await memory.search("database performance")
for r in results:
print(f"[{r.score:.2f}] {r.name}: {r.core}")
# Get formatted context for prompt injection
context = await memory.get_context("database selection criteria")
# Returns: "1. PostgreSQL outperforms MySQL 3x for analytical workloads..."
# Force-crystallize buffered interactions
await memory.flush()

Using with CrewAI

Integrate with CrewAI's task system to give agents context from previous runs:

python
from crewai import Agent, Task, Crew
from neuralsnap_crewai import NeuralSnapCrewMemory
# Shared memory across agents
memory = NeuralSnapCrewMemory(api_key="ns_...")
# Before a task runs, get context
context = await memory.get_context("market research findings")
researcher = Agent(
role="Market Researcher",
goal="Analyze market trends for Q1 2025",
backstory=f"Previous research context:\n{context}",
)
task = Task(
description="Research competitor pricing strategies",
agent=researcher,
)
crew = Crew(agents=[researcher], tasks=[task])
result = crew.kickoff()
# After the task, save what was learned
await memory.save("researcher", result)
await memory.flush() # ensure everything is crystallized

Configuration

PropertyTypeDescription
api_key*stringYour NeuralSnap API key (starts with ns_).
brain_idstringScope all operations to a specific brain. If omitted, uses the default brain.
base_urlstringOverride the NeuralSnap API URL. Default: https://api.neuralsnap.ai/v1
auto_storebooleanAutomatically crystallize significant interactions. Default: true.
auto_recallbooleanAutomatically search for context before tasks. Default: true.
store_intervalnumberCrystallize every N interactions. Default: 5.
recall_limitnumberMax context items returned per search. Default: 5.

Methods

PropertyTypeDescription
save(role, content)asyncSave a conversation turn or crew interaction to the buffer.
search(query, limit?)async → listSearch for relevant memories. Returns MemorySearchResult objects with id, name, core, score.
get_context(query)async → strGet a formatted context string for prompt injection.
flush()asyncForce-crystallize all buffered interactions.
clear()asyncClear the buffer without crystallizing.
buffered_countintNumber of interactions currently buffered.
total_turnsintTotal interactions recorded since initialization.

Early access

The CrewAI integration is in early access (v0.1.0). The save, search, and flush methods are fully defined but connect to the NeuralSnap API in v0.2.0. Install now to lock in the API surface.