def plan_trip(destination: str, owner_id: str = OWNER_ID) -> str:
# 1. Retrieve user preferences
memory_context = get_memory_context(
query=f"travel preferences for {destination}",
owner_id=owner_id,
)
# 2. Create agents with memory-enriched backstories
researcher = Agent(
role="Travel Researcher",
goal=f"Find the best travel options for {destination}",
backstory=(
"You are an expert travel researcher. Consider the traveler's "
f"known preferences:\n{memory_context}"
),
verbose=True,
)
planner = Agent(
role="Trip Planner",
goal=f"Create a detailed itinerary for {destination}",
backstory=(
"You create personalized itineraries. You know this about "
f"the traveler:\n{memory_context}"
),
verbose=True,
)
# 3. Define tasks
research_task = Task(
description=f"Research top attractions, restaurants, and activities in {destination}.",
expected_output="Recommended attractions, restaurants, and activities with descriptions.",
agent=researcher,
)
planning_task = Task(
description=f"Create a 3-day itinerary for {destination} with morning, afternoon, and evening activities.",
expected_output="A detailed 3-day itinerary with times, locations, and tips.",
agent=planner,
)
# 4. Run the crew
crew = Crew(
agents=[researcher, planner],
tasks=[research_task, planning_task],
process=Process.sequential,
verbose=True,
)
result = crew.kickoff()
crew_output = str(result)
# 5. Store results in Cognis
store_crew_result(f"Plan a trip to {destination}", crew_output, owner_id)
return crew_output