from upsonic import Agent, Task
from upsonic.storage.memory import Memory
from upsonic.storage.sqlite import SqliteStorage
# 1. Create persistent storage
storage = SqliteStorage(db_file="./support.db")
# 2. Configure memory with all features
memory = Memory(
storage=storage,
session_id="support_001",
user_id="customer_123",
full_session_memory=True, # Remember conversation
summary_memory=True, # Generate summaries
user_analysis_memory=True, # Learn about customer
num_last_messages=10, # Keep last 10 turns
model="openai/gpt-4o"
)
# 3. Create support agent
agent = Agent(
model="openai/gpt-4o",
name="Support Agent",
memory=memory
)
# 4. First interaction
result1 = agent.do(Task("I'm having trouble logging in to my account"))
print("Response 1:", result1)
# 5. Follow-up - agent remembers context
result2 = agent.do(Task("I tried resetting my password but didn't get the email"))
print("Response 2:", result2)
# 6. Agent references previous context
result3 = agent.do(Task("What have I told you about my issue?"))
print("Response 3:", result3)