import os
from crewai import Agent, Task, Crew
from crewai_memanto import MemantoSetup, create_memanto_tools
# 1. Set up Memanto (one-time per session)
api_key = os.getenv("MOORCHEH_API_KEY")
setup = MemantoSetup(api_key=api_key)
client = setup.setup(agent_id="my-crew-agent")
# 2. Create memory tools bound to your agent
tools = create_memanto_tools(client, agent_id="my-crew-agent")
# 3. Give agents Memanto tools
researcher = Agent(
role="Research Analyst",
goal="Gather and store key facts about the topic",
backstory="You are thorough and always save important findings for future reference.",
tools=[tools["remember"], tools["recall"]], # Persistent memory!
verbose=True
)
writer = Agent(
role="Content Writer",
goal="Write a report using previously stored research",
backstory="You rely on stored research to write accurate, grounded content.",
tools=[tools["recall"], tools["answer"]], # Reads persistent memory!
verbose=True
)
research_task = Task(
description="Research the latest trends in AI agents and store 5 key findings.",
expected_output="Confirmation that 5 findings have been stored in memory.",
agent=researcher
)
write_task = Task(
description="Recall the stored AI agent findings and write a concise summary report.",
expected_output="A 3-paragraph summary report grounded in recalled memory.",
agent=writer
)
# 4. Run the crew with memory=False to prevent dual memory systems
crew = Crew(
agents=[researcher, writer],
tasks=[research_task, write_task],
memory=False, # Memanto handles memory via tools
verbose=True
)
result = crew.kickoff()
print(result)