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

# Team Learning: User Profile

> Team learns and recalls user profile across sessions.

```python team_user_profile.py theme={null}
"""
Team Learning: User Profile
===========================
Team learns and recalls user profile across sessions.

This demonstrates that Team.add_learnings_to_context works correctly:
- Session 1: Team extracts user profile from conversation
- Session 2: Team recalls profile in new session (different session_id)
"""

from agno.agent import Agent
from agno.db.postgres import PostgresDb
from agno.models.openai import OpenAIResponses
from agno.team import Team

db = PostgresDb(db_url="postgresql+psycopg://ai:ai@localhost:5532/ai")

researcher = Agent(
    name="Researcher",
    model=OpenAIResponses(id="gpt-5.2"),
    role="Research and provide detailed information.",
)

writer = Agent(
    name="Writer",
    model=OpenAIResponses(id="gpt-5.2"),
    role="Write clear, concise content.",
)

team = Team(
    name="Content Team",
    model=OpenAIResponses(id="gpt-5.2"),
    members=[researcher, writer],
    db=db,
    learning=True,
    markdown=True,
)

if __name__ == "__main__":
    user_id = "profile_test@example.com"

    print("\n" + "=" * 60)
    print("SESSION 1: Share profile information")
    print("=" * 60 + "\n")

    team.print_response(
        "Hi, I'm Marcus. I'm a DevOps engineer at a fintech startup. "
        "I prefer practical examples over theory, and I work primarily with Kubernetes.",
        user_id=user_id,
        session_id="profile_session_1",
        stream=True,
    )

    lm = team.learning_machine
    print("\n--- Extracted Profile ---")
    lm.user_profile_store.print(user_id=user_id)

    print("\n" + "=" * 60)
    print("SESSION 2: Team should recall profile (NEW SESSION)")
    print("=" * 60 + "\n")

    team.print_response(
        "What do you know about me? Keep it brief.",
        user_id=user_id,
        session_id="profile_session_2",
        stream=True,
    )
```

## Run the Example

<Snippet file="create-venv-step.mdx" />

**1. Install dependencies**

```bash theme={null}
uv pip install -U agno "psycopg[binary]" openai sqlalchemy
```

**2. Export your OpenAI API key**

```bash Mac/Linux theme={null}
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

<Snippet file="run-pgvector-step.mdx" />

**3. Run the example**

Save the code above as `team_user_profile.py`, then run:

```bash theme={null}
python team_user_profile.py
```

Full source: [cookbook/03\_teams/12\_learning/07\_team\_user\_profile.py](https://github.com/agno-agi/agno/blob/v3.0.4/cookbook/03_teams/12_learning/07_team_user_profile.py)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.