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

# Learning

> LearningMachine in Dash, Contacts, and Investment.

A useful agent gets sharper the more you use it: generic patterns at first, your conventions after a few weeks of use, eventually anticipating what you need. That compounding behavior comes from `LearningMachine`. Three agents in the demo use it.

| Agent                                                                        | What it learns                                                        |
| ---------------------------------------------------------------------------- | --------------------------------------------------------------------- |
| [Dash](https://github.com/agno-agi/demo-os/tree/main/agents/dash)            | Schema gotchas, validated query patterns, error fixes that worked     |
| [Contacts](https://github.com/agno-agi/demo-os/tree/main/agents/contacts)    | People, relationships, events, your communication preferences         |
| [Investment](https://github.com/agno-agi/demo-os/tree/main/teams/investment) | Past investment decisions, framework refinements, pattern recognition |

## The shape

```python theme={null}
from agno.learn import (
    LearningMachine, LearningMode,
    UserProfileConfig, EntityMemoryConfig, SessionContextConfig,
    LearnedKnowledgeConfig,
)

contacts = Agent(
    learning=LearningMachine(
        user_profile=UserProfileConfig(mode=LearningMode.ALWAYS),
        entity_memory=EntityMemoryConfig(
            mode=LearningMode.AGENTIC,
            enable_create_entity=True,
            enable_add_fact=True,
            enable_add_relationship=True,
            enable_add_event=True,
        ),
        session_context=SessionContextConfig(
            mode=LearningMode.ALWAYS,
            enable_planning=True,
        ),
    ),
    ...
)
```

Four learning stores, each opt-in:

| Store                                                   | Holds                                           | Mode                                    |
| ------------------------------------------------------- | ----------------------------------------------- | --------------------------------------- |
| [User profile](/learning/stores/user-profile)           | Preferences, role, working style                | `ALWAYS` (auto-extracted every run)     |
| [Entity memory](/learning/stores/entity-memory)         | People, projects, relationships, events         | `AGENTIC` (agent decides when to write) |
| [Session context](/learning/stores/session-context)     | Plans and structure for the current session     | `ALWAYS`                                |
| [Learned knowledge](/learning/stores/learned-knowledge) | Discovered patterns the agent wants to remember | `AGENTIC`                               |

`LearningMode.ALWAYS` runs the extractor on every turn. `LearningMode.AGENTIC` gives the agent tools to write learnings when it judges them worth keeping. See [Learning Modes](/learning/learning-modes).

## Why this beats vanilla memory

Vanilla `enable_agentic_memory=True` gives you one bucket. The agent dumps facts into it. Useful, but flat.

`LearningMachine` separates concerns:

* **User profile** is "this is who I'm talking to" (one record, updated in place).
* **Entity memory** is "this is who/what they're talking about" (graph of nodes and edges).
* **Session context** is "this is the plan for this conversation" (scoped to one session).
* **Learned knowledge** is "this is something I want to remember for next time" (general patterns).

Each store has its own retrieval path. The agent gets the right slice of memory at the right point in the run.

## Dash's learning loop

Dash uses learning differently. The Engineer agent runs SQL, hits errors, diagnoses them, and saves the fix as learned knowledge:

```python theme={null}
from agno.learn import LearnedKnowledgeConfig, LearningMode

dash_learnings = Knowledge(...)

dash_engineer = Agent(
    learning=LearningMachine(
        knowledge=dash_learnings,
        learned_knowledge=LearnedKnowledgeConfig(mode=LearningMode.AGENTIC),
    ),
)
```

The agent gets `save_learning(title, learning)` and `search_learnings(query)` tools. Once. The next time the same error pattern shows up, it pulls the fix from learnings instead of rediscovering it.

This is what makes the Dash team self-improving. After a few weeks of use, the same questions take fewer iterations because the right-shaped learnings are already in the store.

## See it in action

| Agent    | Try in chat                                                                                                                      |
| -------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Contacts | *"Sarah Chen joined Acme as VP Engineering last month."* → entity gets created, relationship added                               |
| Contacts | *"What do I know about the Acme team?"* → entity memory query, returns people + facts + events                                   |
| Contacts | *"I prefer concise responses."* → user profile updated; future responses get terser                                              |
| Dash     | First time: *"why is churn high?"* → diagnoses, saves learning. Second time: same question, faster, references the saved pattern |

Source: [`agents/contacts/`](https://github.com/agno-agi/demo-os/tree/main/agents/contacts), [`agents/dash/`](https://github.com/agno-agi/demo-os/tree/main/agents/dash), [Learning docs](/learning/overview)

## Next

[MCP →](/demo-os/mcp)
