Give your CrewAI analyst agents persistent CTI memory. They'll query ThreatRecall's knowledge graph mid-task, remember what they found across turns, and produce richer investigations.
pip install crewai)Install the Python adapter in your project.
pip install @threatrecall/langchain-adapter
Import the retriever and wire it as your agent's memory backend.
from crewai import Agent, Crew, Task from threatrecall_langchain import ThreatRecallMemoryRetriever # Configure the retriever with your workspace credentials memory_retriever = ThreatRecallMemoryRetriever( api_key="your_api_key_here", workspace_url="https://app.threatrecall.ai", top_k=5, min_confidence=0.3, )
Create a CrewAI agent with ThreatRecall as its primary source of CTI knowledge.
analyst = Agent(
role="Senior Threat Intelligence Analyst",
goal="Deliver accurate, evidence-backed threat assessments",
backstory="You are a SOC analyst with years of experience correlating CTI data.",
verbose=True,
memory=True, # Enable agent memory
tools=[], # Will use ThreatRecall via the retriever below
)
# Attach the retriever to the agent — CrewAI calls this on every turn
analyst.retriever = memory_retriever
Define a task that asks the agent to use ThreatRecall for real intelligence work.
investigation = Task(
description="Research all known threat actors exploiting CVE-2021-44228 (Log4Shell). "
"For each actor, identify their TTPs, associated campaigns, and any IOCs. "
"Use ThreatRecall to retrieve the relevant data.",
agent=analyst,
expected_output="A structured report with actor names, TTPs, campaigns, and IOCs.",
)
# Run the crew
crew = Crew(agents=[analyst], tasks=[investigation])
result = crew.kickoff()
print(result)
Run the script and watch the agent work.
python crew_setup.py
CrewAI agents with memory=True accumulate context from each task. ThreatRecall enriches this by providing structured CTI on every query — so the agent doesn't start cold on each turn.
# Turn 1: Agent asks "Who exploits Log4Shell?" # → ThreatRecall returns: APT-41, Lazarus Group, Volt Typhoon # → This context is stored in CrewAI's memory # Turn 2: Agent asks "Show me their TTPs" # → Agent already knows the actors → can query TTPs directly # → ThreatRecall returns MITRE ATT&CK techniques for each actor
pip install @threatrecall/langchain-adapter in your project environment. If using a virtual environment, make sure it's activated.
OPENAI_API_KEY environment variable (CrewAI uses it by default for the underlying model). If you need to use a different model, check CrewAI's model configuration docs.