> ## Documentation Index
> Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Memory vs Learning

> Understand the difference between Memory (storage) and Learning (adaptive knowledge extraction)

Memory and Learning are **different but complementary** systems. Memory stores raw data, while Learning extracts actionable knowledge from it.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    subgraph "Memory — What happened?"
        M1[⚡ Short-term]
        M2[💾 Long-term]
        M3[👤 Entity]
        M4[📅 Episodic]
    end

    subgraph "Learning — What should I know?"
        L1[👤 Persona]
        L2[💡 Insights]
        L3[🔄 Patterns]
        L4[⚖️ Decisions]
        L5[📝 Feedback]
        L6[🚀 Improvements]
    end

    classDef memory fill:#6366F1,stroke:#7C90A0,color:#fff
    classDef learn fill:#F59E0B,stroke:#7C90A0,color:#fff

    class M1,M2,M3,M4 memory
    class L1,L2,L3,L4,L5,L6 learn
```

## Key Differences

| Dimension    | Memory                                         | Learning                                          |
| ------------ | ---------------------------------------------- | ------------------------------------------------- |
| **Analogy**  | Notebook / filing cabinet                      | Adaptive brain tissue                             |
| **Question** | "What happened before?"                        | "What should I know going forward?"               |
| **When**     | Every interaction (read/write)                 | Post-interaction analysis                         |
| **How**      | Direct storage (key-value, vector, relational) | LLM-powered extraction + structured stores        |
| **Lifetime** | Session (STM) or persistent (LTM)              | Always persistent, grows over time                |
| **Output**   | Raw conversation history, entity records       | User profiles, behavioral patterns, decision logs |
| **Cost**     | Low (no LLM calls for basic ops)               | Higher (requires LLM extraction step)             |

***

## When to Use Each

<CardGroup cols={2}>
  <Card title="Use Memory When" icon="brain">
    * You need conversation context across sessions
    * You want to store/retrieve specific facts
    * You need entity tracking (people, places)
    * You want lightweight, zero-LLM-cost storage
  </Card>

  <Card title="Use Learning When" icon="graduation-cap">
    * Agents should adapt to user preferences over time
    * You want pattern recognition across interactions
    * You need decision logging and rationale tracking
    * You want self-improvement proposals
  </Card>
</CardGroup>

***

## API Comparison

Memory and Learning are **peer-level systems** — both are top-level `Agent` parameters:

<Tabs>
  <Tab title="Memory Only">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="Assistant",
        instructions="You are a helpful assistant",
        memory=True   # STM + LTM + Entity + Episodic
    )
    ```
  </Tab>

  <Tab title="Learning Only">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent

    agent = Agent(
        name="Assistant",
        instructions="You learn from every interaction",
        learn=True  # Enables AGENTIC mode (auto-learning)
    )
    ```
  </Tab>

  <Tab title="Both Together">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent, LearnConfig

    agent = Agent(
        name="Full Assistant",
        instructions="You remember and learn",
        memory=True,                    # Memory system
        learn=LearnConfig(              # Learning layer
            persona=True,               # User preferences
            insights=True,              # Observations
            patterns=True,              # Reusable knowledge
            decisions=True,             # Decision logging
        )
    )
    ```
  </Tab>

  <Tab title="Custom Config">
    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent, LearnConfig

    agent = Agent(
        name="Production Agent",
        instructions="You learn and adapt",
        learn=LearnConfig(
            persona=True,
            insights=True,
            patterns=True,
            mode="agentic",          # Auto-extract learnings
            scope="private",         # User-isolated data
        )
    )
    ```
  </Tab>
</Tabs>

<Note>
  `learn=True` auto-creates a minimal memory backend if `memory=` is not set. Learning works independently — you don't need to configure memory to use it.
</Note>

***

## What Each System Stores

### Memory Types

| Type           | What It Stores                                  | Persistence                  |
| -------------- | ----------------------------------------------- | ---------------------------- |
| **Short-term** | Recent conversation context                     | Rolling buffer, auto-expires |
| **Long-term**  | Important facts with importance scores          | Permanent                    |
| **Entity**     | Named entities (people, places) with attributes | Permanent                    |
| **Episodic**   | Date-based interaction history                  | Configurable retention       |

### Learning Stores

| Store            | What It Extracts                      | Default |
| ---------------- | ------------------------------------- | ------- |
| **Persona**      | User preferences, communication style | ✅ On    |
| **Insights**     | Observations and learnings            | ✅ On    |
| **Thread**       | Session context                       | ✅ On    |
| **Patterns**     | Reusable knowledge patterns           | ❌ Off   |
| **Decisions**    | Decision rationale and trade-offs     | ❌ Off   |
| **Feedback**     | Outcome signals and corrections       | ❌ Off   |
| **Improvements** | Self-improvement proposals            | ❌ Off   |

***

## How They Work Together

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Memory
    participant Learning

    User->>Agent: "I prefer Python over JavaScript"
    Agent->>Memory: Store in STM (raw text)
    Agent->>Memory: Add Entity (User → prefers: Python)
    Agent->>Learning: Extract Persona (language preference)
    Agent->>Learning: Extract Insight (tech stack signal)
    Agent-->>User: Response

    Note over Agent: Next interaction
    User->>Agent: "Help me build an API"
    Agent->>Memory: Retrieve recent context (STM)
    Agent->>Learning: Get persona + insights
    Agent->>Agent: System prompt includes both
    Agent-->>User: Python-specific API guidance
```

**Memory** provides the raw recall. **Learning** provides the adaptive intelligence on top.

***

## Architecture

Both systems are first-class peers on the Agent:

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph TD
    A["Agent"] --> B["learn= param"]
    A --> C["memory= param"]
    
    B --> D["LearnConfig"]
    D --> E["LearnMode: AGENTIC / PROPOSE / DISABLED"]
    B -.->|"auto-creates if needed"| C
    
    C --> F["MemoryConfig"]
    F --> G["STM / LTM / Entity / RAG"]
    
    A -->|"post-run hook"| H["Auto-extract learnings"]
    H --> I["LearnManager → 7 stores"]
```

### Learning Modes

| Mode         | Behavior                                                                            |
| ------------ | ----------------------------------------------------------------------------------- |
| **AGENTIC**  | Automatically extracts learnings after each interaction (default with `learn=True`) |
| **PROPOSE**  | Agent proposes learnings, human approves                                            |
| **DISABLED** | Learning is off                                                                     |

***

## Related

<CardGroup cols={2}>
  <Card title="Memory" icon="brain" href="/concepts/memory">
    Complete memory guide — types, backends, API
  </Card>

  <Card title="Agent Learn" icon="graduation-cap" href="/concepts/agent-learn">
    Learning stores, configuration, CLI
  </Card>

  <Card title="Context vs Memory" icon="scale-balanced" href="/concepts/context-vs-memory">
    Context window vs persistent memory
  </Card>

  <Card title="Knowledge vs Memory vs Context" icon="book" href="/concepts/knowledge-memory-context-rag">
    Full comparison of all data systems
  </Card>
</CardGroup>
