Skip to main content
from praisonaiagents import Agent, LearnConfig

agent = Agent(
    name="Personal Assistant",
    instructions="You are a helpful assistant that remembers user preferences.",
    learn=LearnConfig(
        persona=True,
        insights=True,
        mode="agentic",
    )
)

agent.start("I prefer concise answers with bullet points")
Agents learn from every interaction — capturing user preferences, insights, and patterns to improve future responses automatically. The user interacts with the agent; learnings are extracted and stored, then recalled in future sessions.

Quick Start

1

Enable Learning with Defaults

from praisonaiagents import Agent

agent = Agent(
    name="Learning Agent",
    instructions="You are a helpful assistant",
    learn=True
)

agent.start("I work in Python and prefer type hints")
2

Configure Learning Capabilities

from praisonaiagents import Agent, LearnConfig

agent = Agent(
    name="Smart Assistant",
    instructions="Remember my preferences and insights.",
    learn=LearnConfig(
        persona=True,
        insights=True,
        patterns=True,
        mode="agentic",
    )
)

agent.start("Always format code examples with type annotations")
3

Use a Database Backend

from praisonaiagents import Agent, LearnConfig

agent = Agent(
    name="Persistent Learner",
    instructions="Store learnings in a database.",
    learn=LearnConfig(
        backend="sqlite",
        db_url="sqlite:///learn.db",
        persona=True,
        insights=True,
    )
)

agent.start("My timezone is UTC+5:30")

How It Works


Choose a Learning Mode

Choose a Storage Backend


Configuration Options

LearnConfig Python Reference

Full parameter reference for LearnConfig
OptionTypeDefaultDescription
personaboolTrueCapture user preferences and profile
insightsboolTrueCapture observations and learnings
threadboolTrueCapture session/conversation context
patternsboolFalseCapture reusable knowledge patterns
decisionsboolFalseLog decision history
feedbackboolFalseCapture outcome signals
improvementsboolFalseSelf-improvement proposals
modestr"disabled""disabled", "agentic", or "propose"
backendstr"file""file", "sqlite", "redis", or "mongodb"
db_urlstr | NoneNoneDatabase connection URL (non-file backends)
store_pathstr | NoneNoneCustom path for file backend
max_entriesint0Max entries per store (0 = unbounded)
retention_daysint0Archive entries unused for N days (0 = keep forever)
llmstr | NoneNoneLLM for learning extraction (defaults to agent’s LLM)
scopestr"private""private" or "shared"
nudge_intervalint0Nudge agent every N turns (0 = disabled)
nudge_min_tool_itersint3Minimum tool iterations before a nudge fires
propose_skillsboolFalseEnable skill_manage tool in propose mode

Common Patterns

Self-improving assistant with retention governance:
from praisonaiagents import Agent, LearnConfig

agent = Agent(
    name="Adaptive Assistant",
    instructions="Adapt to user preferences over time.",
    learn=LearnConfig(
        persona=True,
        insights=True,
        patterns=True,
        mode="agentic",
        max_entries=500,
        retention_days=90,
    )
)
Shared learnings across a team of agents:
from praisonaiagents import Agent, LearnConfig

shared_learn = LearnConfig(
    scope="shared",
    backend="sqlite",
    db_url="sqlite:///team_learnings.db",
    persona=True,
    insights=True,
)

researcher = Agent(name="Researcher", instructions="Research topics.", learn=shared_learn)
writer = Agent(name="Writer", instructions="Write content.", learn=shared_learn)

Best Practices

Enable learning with defaults first. Once you understand what gets captured, switch to LearnConfig to enable only the capabilities you need (persona, insights, patterns).
Set mode="agentic" to have the agent automatically extract and store learnings after each conversation. This requires no manual action from users or developers.
Use max_entries and retention_days to prevent unbounded growth. A limit of max_entries=1000 with retention_days=180 keeps the learning store manageable.
The default file backend stores JSON in ~/.praison. For production or multi-instance setups, use backend="sqlite" or backend="redis" with a db_url.

Memory Config

Session and persistent memory configuration

Agent Learning

Agent learn feature overview

Learning Retention

Govern how long learnings are kept

Learn Skill

Teach agents new skills dynamically