# Team Performance with Memory (/evals/performance/usage/performance-team-with-memory)



Before running the code, provide a PostgreSQL database named `ai` on `localhost:5532` with username and password `ai`, matching the example URL. For a local disposable database, run:

```bash
docker run --name agno-eval-db -e POSTGRES_DB=ai -e POSTGRES_USER=ai -e POSTGRES_PASSWORD=ai -p 5532:5432 -d postgres:18
```

Wait for the database to accept connections. If you already have PostgreSQL, adjust the example’s `db_url` to match it. Reuse the same local container across examples; do not run this creation command again with the same name.

<Steps>
  <Step title="Create a Python file">
    ```python title="performance_team_with_memory.py"
    import asyncio
    import random

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

    cities = [
        "New York",
        "Los Angeles",
        "Chicago",
        "Houston",
        "Miami",
        "San Francisco",
        "Seattle",
        "Boston",
        "Washington D.C.",
        "Atlanta",
        "Denver",
        "Las Vegas",
    ]


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


    def get_weather(city: str) -> str:
        return f"The weather in {city} is sunny."


    weather_agent = Agent(
        id="weather_agent",
        model=OpenAIResponses(id="gpt-5.2"),
        role="Weather Agent",
        description="You are a helpful assistant that can answer questions about the weather.",
        instructions="Be concise, reply with one sentence.",
        tools=[get_weather],
        db=db,
        update_memory_on_run=True,
        add_history_to_context=True,
    )

    team = Team(
        members=[weather_agent],
        model=OpenAIResponses(id="gpt-5.2"),
        instructions="Be concise, reply with one sentence.",
        db=db,
        markdown=True,
        update_memory_on_run=True,
        add_history_to_context=True,
    )


    async def run_team():
        random_city = random.choice(cities)
        async for _ in team.arun(
            input=f"I love {random_city}! What weather can I expect in {random_city}?",
            stream=True,
            stream_events=True,
        ):
            pass

        return "Successfully ran team"


    team_response_with_memory_impact = PerformanceEval(
        name="Team Memory Impact",
        func=run_team,
        num_iterations=5,
        warmup_runs=0,
        measure_runtime=False,
        debug_mode=True,
        memory_growth_tracking=True,
    )

    if __name__ == "__main__":
        asyncio.run(
            team_response_with_memory_impact.arun(print_results=True, print_summary=True)
        )
    ```
  </Step>

    <Step title="Set up your virtual environment">
      <CodeBlockTabs defaultValue="Mac">
        <CodeBlockTabsList>
          <CodeBlockTabsTrigger value="Mac">
            Mac
          </CodeBlockTabsTrigger>

          <CodeBlockTabsTrigger value="Windows">
            Windows
          </CodeBlockTabsTrigger>
        </CodeBlockTabsList>

        <CodeBlockTab value="Mac">
          ```bash
          uv venv --python 3.12
          source .venv/bin/activate
          ```
        </CodeBlockTab>

        <CodeBlockTab value="Windows">
          ```bash
          uv venv --python 3.12
          .venv\Scripts\activate
          ```
        </CodeBlockTab>
      </CodeBlockTabs>
    </Step>

  <Step title="Install dependencies">
    ```bash
    uv pip install -U openai agno psycopg sqlalchemy
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeBlockTabs defaultValue="Mac/Linux">
      <CodeBlockTabsList>
        <CodeBlockTabsTrigger value="Mac/Linux">
          Mac/Linux
        </CodeBlockTabsTrigger>

        <CodeBlockTabsTrigger value="Windows">
          Windows
        </CodeBlockTabsTrigger>
      </CodeBlockTabsList>

      <CodeBlockTab value="Mac/Linux">
        ```bash
          export OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>

      <CodeBlockTab value="Windows">
        ```bash
          $Env:OPENAI_API_KEY="your_openai_api_key_here"
        ```
      </CodeBlockTab>
    </CodeBlockTabs>
  </Step>

  <Step title="Run Team">
    ```bash
    python performance_team_with_memory.py
    ```
  </Step>
</Steps>
