Give your CrewAI agents persistent memory of user preferences. pref0 learns from conversations and personalizes multi-agent workflows.
from crewai import Agent, Task, Crew
import requests
PREF0_API = "https://api.pref0.com"
PREF0_KEY = "pref0_sk_..."
def get_preferences(user_id: str) -> str:
res = requests.get(
f"{PREF0_API}/v1/profiles/{user_id}",
headers={"Authorization": f"Bearer {PREF0_KEY}"},
)
prefs = res.json().get("preferences", [])
return "\n".join(
f"- {p['key']}: {p['value']} (confidence: {p['confidence']})"
for p in prefs if p["confidence"] >= 0.5
)
learned = get_preferences("user_abc123")
coder = Agent(
role="Senior Developer",
goal="Write code following user preferences",
backstory=f"You know the user's preferences:\n{learned}",
)
task = Task(
description="Set up a new API project",
agent=coder,
expected_output="Project scaffolding code",
)
crew = Crew(agents=[coder], tasks=[task])
result = crew.kickoff()Inject user preferences into individual agent backstories. Each agent in the crew respects the user's style.
All agents in a crew share the same learned preferences. No conflicting outputs.
Preferences persist across crew runs. The crew gets smarter with every interaction.
No custom tools or plugins needed. Just fetch preferences and pass them to your agents.
Your users are already teaching your agent what they want. pref0 makes sure the lesson sticks.