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

# Agent with Memory

## Code

```python cookbook/models/vllm/memory.py theme={null}
from agno.agent import Agent
from agno.memory.v2.db.postgres import PostgresMemoryDb
from agno.memory.v2.memory import Memory
from agno.models.vllm import vLLM
from agno.storage.postgres import PostgresStorage

DB_URL = "postgresql+psycopg://ai:ai@localhost:5532/ai"

agent = Agent(
    model=vLLM(id="microsoft/Phi-3-mini-128k-instruct"),
    memory=Memory(
        db=PostgresMemoryDb(table_name="agent_memory", db_url=DB_URL),
    ),
    enable_user_memories=True,
    enable_session_summaries=True,
    storage=PostgresStorage(
        table_name="personalized_agent_sessions",
        db_url=DB_URL,
    ),
)

# Share personal details; the agent should remember them.
agent.print_response("My name is John Billings.", stream=True)
print("Current memories →")
pprint(agent.memory.memories)
print("Current summary →")
pprint(agent.memory.summaries)

agent.print_response("I live in NYC.", stream=True)
print("Memories →")
pprint(agent.memory.memories)
print("Summary →")
pprint(agent.memory.summaries)

agent.print_response("I'm going to a concert tomorrow.", stream=True)
print("Memories →")
pprint(agent.memory.memories)
print("Summary →")
pprint(agent.memory.summaries)

# Ask the agent to recall
agent.print_response(
    "What have we been talking about, do you know my name?", stream=True
)
```

<Note>
  Ensure Postgres database is running.
</Note>

## Usage

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

  <Step title="Start Postgres database">
    ```bash theme={null}
    ./cookbook/scripts/run_pgvector.sh
    ```
  </Step>

  <Step title="Install Libraries">
    ```bash theme={null}
    pip install -U agno openai vllm sqlalchemy psycopg[binary] pgvector
    ```
  </Step>

  <Step title="Start vLLM server">
    ```bash theme={null}
    vllm serve microsoft/Phi-3-mini-128k-instruct \
        --dtype float32 \
        --enable-auto-tool-choice \
        --tool-call-parser pythonic
    ```
  </Step>

  <Step title="Run Agent">
    ```bash theme={null}
    python cookbook/models/vllm/memory.py
    ```
  </Step>
</Steps>
