from praisonaiagents import Agent, Task, PraisonAIAgents, Session
from praisonaiagents.tools import duckduckgo
from pydantic import BaseModel
# Structured output schema
class ResearchReport(BaseModel):
topic: str
summary: str
key_findings: list[str]
sources: list[str]
recommendations: list[str]
# Create session for resumability
session = Session(session_id="research-001", user_id="user-1")
# Agent with memory and tools
agent = Agent(
name="Researcher",
instructions="Research topics thoroughly and return structured reports.",
tools=[duckduckgo],
memory=True
)
# Task with structured output
task = Task(
description="Research the current state of quantum computing in 2024",
expected_output="Structured research report",
agent=agent,
output_pydantic=ResearchReport
)
# Run with SQLite persistence
agents = PraisonAIAgents(
agents=[agent],
tasks=[task],
memory=True,
memory_config={"provider": "sqlite", "db_path": "research.db"},
verbose=1
)
result = agents.start()
print(result)
# Resume later
session2 = Session(session_id="research-001", user_id="user-1")
history = session2.search_memory("quantum computing")