Skip to main content
Make your agent smarter over time — it learns from every conversation and applies those insights automatically.
from praisonaiagents import Agent

agent = Agent(
    name="LearningAssistant",
    instructions="You are a helpful personal assistant.",
    learn=True  # Agent captures and reuses learnings automatically
)

result = agent.start("I prefer concise bullet points over long paragraphs")
print(result)
The user shares preferences in chat; the agent stores learnings and applies them on the next turn.

Quick Start

1

Simple Usage

Enable learning with a boolean — the agent captures persona and insights by default:
from praisonaiagents import Agent

agent = Agent(
    name="PersonalAssistant",
    instructions="You are my personal assistant.",
    learn=True
)

agent.start("Remember: I always want responses in markdown format")
2

With LearnConfig

Choose what to learn and how to store it:
from praisonaiagents import Agent, LearnConfig

agent = Agent(
    instructions="You are a helpful assistant.",
    learn=LearnConfig(
        persona=True,
        insights=True,
        patterns=True,
        mode="agentic",
    ),
)
agent.start("I work in finance and need data-focused answers.")
3

With Database Backend

from praisonaiagents import Agent, LearnConfig

agent = Agent(
    instructions="You are a helpful assistant.",
    learn=LearnConfig(
        backend="sqlite",
        db_url="sqlite:///learn.db",
        mode="agentic",
    ),
)
agent.start("My team prefers Python over JavaScript for all scripts.")

How It Works

PhaseWhat happens
1. ConversationUser interacts with the agent normally
2. ExtractAgent identifies persona, insights, and patterns
3. StoreLearnings saved to the configured backend
4. ApplyFuture responses adapt based on stored learnings

Learning Modes

mode="propose" is defined in the SDK but not yet implemented — it behaves the same as disabled until the approval workflow is added. Do not use it in production.

Configuration Options

LearnConfig SDK Reference

Full parameter reference for LearnConfig
Precedence ladder:
# Level 1: Bool (enable with defaults)
agent = Agent(learn=True)

# Level 2: LearnConfig (full control)
agent = Agent(learn=LearnConfig(
    persona=True,
    mode="agentic",
    backend="sqlite",
))
What the agent can learn:
OptionTypeDefaultDescription
personaboolTrueUser preferences and profile
insightsboolTrueObservations from conversations
threadboolTrueSession/conversation context
patternsboolFalseReusable knowledge patterns
decisionsboolFalseLog decisions made
feedbackboolFalseCapture outcome signals
improvementsboolFalseSelf-improvement proposals
Learning mode:
OptionTypeDefaultDescription
modestr"disabled""disabled" / "agentic" / "propose" (see note)
scopestr"private""private" (per user) or "shared" (all agents)
nudge_intervalint0Nudge agent to reflect every N turns (0 = off)
propose mode is defined in the SDK but not yet implemented. Setting mode="propose" currently behaves the same as "disabled".
Storage backend:
OptionTypeDefaultDescription
backendstr"file""file" / "sqlite" / "redis" / "mongodb"
db_urlstr | NoneNoneConnection URL for non-file backends
store_pathstr | NoneNoneCustom path for file backend
max_entriesint0Max stored entries (0 = unlimited)
retention_daysint0Archive entries older than N days (0 = keep forever)
llmstr | NoneNoneLLM model for extracting learnings

Full list of options, types, and defaults — LearnConfig
OptionTypeDefaultDescription
personaboolTrueCapture user preferences and profile
insightsboolTrueStore observations and learnings
threadboolTrueTrack session/conversation context
patternsboolFalseReusable knowledge patterns
decisionsboolFalseDecision logging
feedbackboolFalseOutcome signals
improvementsboolFalseSelf-improvement proposals
modestr"disabled""disabled" or "agentic"
scopestr"private""private" or "shared"
backendstr"file""file", "sqlite", "redis", "mongodb"
db_urlstr | NoneNoneDatabase connection URL
store_pathstr | NoneNoneCustom file storage path
max_entriesint0Per-store cap (0 = unbounded)
retention_daysint0Archive stale entries after N days (0 = never)
llmstr | NoneNoneLLM for extracting learnings
nudge_intervalint0Nudge every N turns (0 = disabled)

Common Patterns

Pattern 1 — Persona learning for personalized responses

from praisonaiagents import Agent, LearnConfig

agent = Agent(
    name="PersonalCoach",
    instructions="You are a personal productivity coach.",
    learn=LearnConfig(
        persona=True,
        insights=True,
        patterns=True,
        mode="agentic",
        backend="sqlite",
        db_url="sqlite:///coach_memory.db",
    )
)

# The agent builds a profile of you over time
agent.start("I struggle with time management in the mornings")
agent.start("I prefer evening workouts")
agent.start("What routine would work best for me?")
Shared learning across agents:
from praisonaiagents import Agent, LearnConfig

shared_learn = LearnConfig(
    insights=True,
    patterns=True,
    scope="shared",  # All agents share this learning store
    backend="redis",
    db_url="redis://localhost:6379",
)

agent1 = Agent(name="SupportAgent1", instructions="Handle customer support.", learn=shared_learn)
agent2 = Agent(name="SupportAgent2", instructions="Handle customer support.", learn=shared_learn)
Nudge-based self-improvement: instructions=“You are a writing assistant.”, learn=LearnConfig(persona=True, insights=True, mode=“agentic”), ) response = agent.start(“I prefer formal British English in all my documents.”) print(response)

### Pattern 2 — Shared patterns across agents
```python
from praisonaiagents import Agent, LearnConfig

agent = Agent(
    name="ImprovingAgent",
    instructions="You are a coding assistant that gets better over time.",
    learn=LearnConfig(
        improvements=True,
        nudge_interval=5,  # Reflect and propose improvements every 5 turns
        nudge_min_tool_iters=3,  # Only nudge if agent did real work
    )
)

Best Practices

The default settings (persona=True, insights=True) cover most use cases. Only add patterns=True or decisions=True when you need those specific learning types — they add overhead per turn.
The default file backend is great for development and local agents. For production, switch to sqlite (single-node) or redis/mongodb (multi-node or high throughput).
For long-lived agents, set max_entries (e.g., max_entries=1000) and retention_days (e.g., retention_days=30) to prevent the learning store from growing indefinitely.
Shared learning means all agents read and write to the same store. This is powerful for multi-agent coordination but can cause unexpected behavior if different agents learn conflicting patterns.

Learning Retention

How learned data persists between sessions

Advanced Memory

Full memory system configuration

Learn Skill

Agent skill learning system

Self Improve

Agent self-improvement mechanisms