from praisonaiagents import Agentagent = Agent( name="Neon Agent", instructions="You are a helpful assistant with persistent memory.", db={"database_url": "postgresql://user:pass@ep-xxx.neon.tech/db?sslmode=require"})# Start conversationresult = agent.start("Remember that I work at TechCorp as a developer")print(result)
3
Test Persistence
# Later session - agent remembers previous conversationresult = agent.start("What company do I work for?")print(result) # "You work at TechCorp as a developer"
# Create a branch for testingneon branches create --name agent-testing --parent main# Get branch connection stringneon connection-string agent-testing
# Use branch for developmentdev_db = NeonDB(database_url="postgresql://...@ep-xxx-branch.neon.tech/db")dev_agent = Agent(name="Dev Agent", db=dev_db)# Test new conversation flows without affecting productionresult = dev_agent.start("Test new features here")
Neon automatically pools connections, but you can tune for your workload:
from praisonai.db.adapter import NeonDBdb = NeonDB( database_url="postgresql://...?sslmode=require", pool_size=10, # Larger pool for high-concurrency agents max_retries=3, # Standard retry for Neon cold starts)
Neon databases auto-suspend after 5 minutes of inactivity. The first connection takes ~500ms-2s:
from praisonai.db.adapter import NeonDB# Optimize retry settings for cold startsdb = NeonDB( database_url="postgresql://...", max_retries=5, # Extra retries for wake-up retry_delay=1.0, # 1 second between retries)
Use SSL Connections
Neon requires SSL for all connections. PraisonAI auto-adds sslmode=require:
# Both are equivalent - SSL is enforced automaticallydb1 = NeonDB(database_url="postgresql://user:pass@ep-xxx.neon.tech/db")db2 = NeonDB(database_url="postgresql://user:pass@ep-xxx.neon.tech/db?sslmode=require")
Monitor Usage
Track your database usage in the Neon dashboard:
Compute time: Billed per second of activity
Storage: Grows with conversation history
Data transfer: Minimal for typical agent workloads
Set up alerts before hitting free tier limits (0.5GB storage, 100 hours compute/month).