PII Agent is an AI agent demo that interacts with personally identifiable information (PII) stored in a PostgreSQL database. You ask questions in plain English, and the agent translates them into SQL queries, runs them, and returns the results.
This guide walks you through every step from a fresh clone to a running agent session.
- A running PostgreSQL 16 container holding 30 sample PII records
- A working Python environment with all agent dependencies installed
- At least one agent (MSFT Agent Framework or Agno) accepting natural language queries
| Tool | Version | Purpose |
|---|---|---|
| Python | 3.12 | Agent runtime |
| uv | Any recent | Package and virtual environment manager |
| Docker | Any recent | Runs the PostgreSQL container |
| A LiteLLM-compatible API endpoint | — | Powers the agent LLM calls |
Verify each before proceeding:
python --version
uv --version
docker --versiongit clone <repository-url>
cd pii-agentuv venv
source .venv/bin/activate # macOS / Linux
# .venv\Scripts\activate # Windowscp .env.sample .envLLM_API_KEY=<your-api-key>
LLM_BASE_URL=<your-gateway-url>
LLM_MODEL_ID=<model-identifier>
# Core data dependencies (required for all agents)
uv pip install -r data/requirements.txt
# MSFT Agent Framework
uv pip install -r src/msft-agent-framework/requirements.txt
# Agno Agent (install manually)
uv pip install agno python-dotenvdocker compose -f data/docker-compose.yml up -d| Setting | Value |
|---|---|
| Host | localhost |
| Port | 5432 |
| Database | pii_demo |
| Username | postgres |
| Password | MyDbPassword |
Verify the container is running:
docker ps --filter name=piipython -m data.load_csv
# Expected: Loaded 30 new rows into persons table.This is idempotent — safe to run multiple times. Re-running prints "Loaded 0 new rows."
| Category | Fields |
|---|---|
| Identity | id, fname, lname, maiden_name, gender, birthdate |
| Contact | address, city, state, zip, phone, email |
| Financial | cc_type, cc_number, cc_cvc, cc_expiredate |
# Unit tests (no database required — uses in-memory SQLite)
python -m pytest data/tests/ -v
# Smoke tests (requires running database with data loaded)
python -m pytest src/msft-agent-framework/test_tools.py -vpython src/msft-agent-framework/data-agent.pyExample queries:
- "What tables are available?"
- "Show me all records for people in California."
- "What is the breakdown of records by gender?"
Type quit or exit to stop.
python src/agno/db-agent.pyEdit agent.print_response(...) in src/agno/db-agent.py to change the query.
| Variable | Required | Default |
|---|---|---|
LLM_API_KEY |
Yes | None |
LLM_BASE_URL |
Yes | None |
LLM_MODEL_ID |
Yes (MSFT agent) | gpt-4o |
DATABASE_URL |
No | postgresql+psycopg://postgres:MyDbPassword@localhost:5432/pii_demo |
DB_CONNINFO |
No | host=localhost port=5432 dbname=pii_demo user=postgres password=MyDbPassword |
Start Docker Desktop (macOS/Windows) or sudo systemctl start docker (Linux).
Stop the conflicting Postgres instance, or change the host port in data/docker-compose.yml
and update DATABASE_URL / DB_CONNINFO accordingly.
Copy from .env.sample and replace <placeholders> with real values — no angle brackets.
The container is not running. Run docker compose -f data/docker-compose.yml up -d first.
Default credentials are postgres / MyDbPassword. Match these in your env vars if you
changed docker-compose.yml.
Run python -m data.load_csv before the smoke tests.
LLM call is likely failing. Verify LLM_BASE_URL, LLM_API_KEY, and LLM_MODEL_ID in .env.
Run commands from the project root with the virtual environment active:
source .venv/bin/activate
cd /path/to/pii-agent
python -m data.load_csv