Continuous learning with learn=True and LearnConfig
Let agents capture persona, patterns, and decisions automatically
Writing manual save-fact calls for every preference gets tedious. Pass learn=True or LearnConfig(persona=True, patterns=True, decisions=True, scope=LearnScope.PRIVATE) so your agent distills durable learnings across sessions automatically.
Example
from praisonai import Agent, LearnConfig, LearnScope, LearnMode
learn_cfg = LearnConfig(
persona=True,
patterns=True,
decisions=True,
scope=LearnScope.PRIVATE,
mode=LearnMode.AGENTIC,
retention_days=90,
)
coach = Agent(
name='AdaptiveCoach',
instructions='Adapt your explanation concisely to the user experience level.',
output='silent',
)
print('LearnConfig ->', learn_cfg.scope.value, '|', learn_cfg.mode.value, '| retention:', learn_cfg.retention_days)
print('Reply:', coach.start('I am a senior Python engineer; explain decorators in 1 sentence.'))Example explained
- LearnScope.PRIVATE — Keeps learned insights scoped strictly to the individual user.
- retention_days=90 — Automatically ages out stale learnings for privacy compliance and signal quality.
Keep retention_days bounded
Preferences change over time (projects end, roles change). Setting retention_days and max_entries keeps learned memory sharp and compliant with data-retention policies.
Common pitfall: turning on shared scope for personal data
Only use shared/team learning scopes for non-personal engineering conventions — keep personal preferences strictly LearnScope.PRIVATE.
Reference: documentation