Mini-project: Persistent personal onboarding assistant
Remember safe profile facts across restarts while blocking secrets
Build a realistic onboarding assistant combining privacy filtering (never store passwords/tokens), per-user FileMemory persistence, checkpointing, and personalized agent replies.
Example
import tempfile
from praisonai import Agent, ExecutionConfig, PreCompactionMemoryFlushConfig
from praisonai.memory import FileMemory
def safe_remember(mem: FileMemory, fact: str) -> bool:
if any(b in fact.lower() for b in ('password', 'sk-', 'secret', 'ssn')):
return False
mem.store_long_term(fact)
return True
with tempfile.TemporaryDirectory() as tmp:
mem = FileMemory(user_id='new_hire_7', base_path=tmp)
saved_role = safe_remember(mem, 'Role: Backend Engineer; stack: Python and PostgreSQL.')
saved_secret = safe_remember(mem, 'My staging password is super-secret-123')
profile = mem.search_long_term('Backend')[0]['item']['content']
buddy = Agent(
name='OnboardingBuddy',
instructions='Give a 2-bullet Day-1 checklist tailored strictly to Profile.',
execution=ExecutionConfig(context_compaction=True, pre_compaction_memory_flush=PreCompactionMemoryFlushConfig(enabled=True)),
output='silent',
)
print('Saved role:', saved_role, '| Blocked secret:', not saved_secret)
print(buddy.start(f'Profile: {profile}\nGive Day-1 checklist.'))Example explained
- safe_remember — Enforces privacy hygiene before any text enters durable storage.
- FileMemory(user_id='new_hire_7') — Persists the new hire's profile cleanly across restarts.
Next course: Skills
With RAG (shared facts) and Memory (personal state) mastered, continue to Skills to package reusable instructions cleanly without bloating prompts.
Reference: documentation