Loading
Loading
Share atlaso across CrewAI roles by subclassing ExternalMemory. The agent tag preserves provenance.
from crewai.memory.external import ExternalMemory
from atlaso import Memory
class AtlasoExternalMemory(ExternalMemory):
def __init__(self, user_id: str):
super().__init__()
self.user = Memory().for_user(user_id)
def save(self, value: str, metadata: dict | None = None, agent: str | None = None) -> None:
tags = ["crewai"]
if agent:
tags.append(f"role={agent}")
self.user.add(value, tags=tags)
def search(self, query: str, limit: int = 5, score_threshold: float = 0.0) -> list[dict]:
hits = self.user.recall(query, limit=limit)
return [
{
"context": h.content,
"metadata": {
"is_confident": h.is_confident,
"has_disagreement": h.has_disagreement,
"score": h.score,
"role": next(
(t.split("=", 1)[1] for t in h.tags if t.startswith("role=")),
None,
),
},
}
for h in hits
if h.score >= score_threshold
]
def reset(self) -> None:
raise NotImplementedError("Atlaso deposits are immutable.")Was this page helpful?