Dash — Self-Learning Database Agent
Dash is a self-learning PostgreSQL tool that turns your agent into a data analyst. It generates SQL from natural language, learns from every interaction, auto-corrects mistakes, and gets smarter over time. Inspired by OpenAI’s in-house data agent and built on the Agno Dash architecture.How It Works
The 6 Layers of Context
When Dash assembles context for SQL generation, it draws from six distinct sources:| Layer | What It Provides | Source |
|---|---|---|
| 1. Schema | Tables, columns, types, PKs, FKs, indexes, row counts | Auto-discovered from database |
| 2. Annotations | Per-table descriptions, per-column notes, metric definitions, business rules | Your configuration |
| 3. Knowledge | Proven query patterns that worked before (hybrid search) | Learned from successful queries |
| 4. Docs | External documentation, policies, MCP context | Your configuration |
| 5. Learnings | Error corrections — what failed and how it was fixed | Learned from query failures |
| 6. Runtime | Live stats, sample data, column distributions | On-demand introspection |
Setup
From the Dashboard
- Go to your agent’s Tools section.
- Click Add Tool and select Dash (Self-Learning DB).
- Fill in the connection details:
- Host — Your PostgreSQL server address
- Database Name — The database to connect to
- Username / Password — Database credentials
- Schema — Default schema (usually
public)
- Optionally configure business annotations (see below).
- Save the agent.
Via the API
Configuration
| Field | Type | Default | Description |
|---|---|---|---|
host | string | Required | PostgreSQL host |
port | integer | 5432 | PostgreSQL port |
db_name | string | Required | Database name |
user | string | Required | Database username |
password | string | Required | Database password |
schema | string | "public" | Default schema |
read_only | boolean | true | Only allow SELECT queries |
enable_learning | boolean | true | Enable self-learning loop |
max_retries | integer | 2 | Auto-correction retry attempts (0-5) |
annotations | object | {} | Business annotations (see below) |
docs_context | string | "" | External documentation context |
Business Annotations
Annotations are the secret to accurate SQL generation. They encode tribal knowledge that exists nowhere in the database schema:Available Functions
Dash registers these functions that the agent can call:| Function | Purpose |
|---|---|
discover_schema() | Auto-discover tables, columns, types, constraints, indexes |
ask_database(question) | Assemble 6-layer context for a natural language question |
run_query(query, question) | Execute SQL with read-only enforcement and learning |
record_correction(original, error, corrected, question) | Store an error correction as a Learning |
get_table_stats(table) | Row counts, numeric stats, null rates, date ranges |
get_sample_data(table, limit) | Preview actual data values |
get_column_distribution(table, column, limit) | Value frequency analysis |
suggest_visualization(result) | Recommend chart types for query results |
Dual Memory System
Dash maintains two types of persistent memory:Knowledge (Proven Patterns)
When a query succeeds, Dash stores it as Knowledge — a validated pattern that future queries can reference. Over time, this builds a library of working SQL for your specific database.Learnings (Error Corrections)
When a query fails and is corrected, Dash stores the before/after pair as a Learning. The next time a similar question comes up, the agent sees the correction and avoids the same mistake.Persistence
Knowledge and learnings are stored in a JSON file keyed by your database connection. They persist across agent restarts and sessions. The store is capped at 500 knowledge patterns and 200 corrections to prevent unbounded growth.Auto-Retry on Errors
When a query fails, Dash doesn’t just return an error. It builds diagnostic context:- Error classification — Identifies the error type (missing column, syntax error, type mismatch, timeout, etc.)
- Relevant past corrections — Searches learnings for similar failures that were previously fixed
- Fix suggestions — Recommends using
discover_schema()orget_table_stats()to verify assumptions
max_retries attempts. If the retry succeeds, the correction is stored as a Learning.
Security
Read-Only Mode (Default)
By default, Dash blocks all data-modifying statements:INSERT,UPDATE,DELETEDROP,TRUNCATE,ALTER,CREATEGRANT,REVOKE,COPY- Piggyback attacks like
SELECT ...; DROP TABLE ...
Query Timeout
All queries have a 30-second timeout to prevent runaway operations.Best Practices
- Always use a read-only database user — Even with read-only mode enabled, defense-in-depth is important.
- Use a replica — Point Dash at a read replica, not your primary database.
- Limit schema access — Only expose the schemas and tables the agent needs.
Example Conversations
Simple Question
Question with Learning
Auto-Correction
Integration with Agent Learning
Dash’s self-learning operates independently but complements the platform’s Agent Learning system:- Dash learnings are SQL-specific — query patterns and corrections stored locally per database
- Agent learnings are conversation-level — feedback and corrections stored in the platform database
Next Steps
- Built-in Tools — Browse all available tools
- Agent Learning — Learn about the platform-wide learning system
- Knowledge Sources — Add documents and data to your agent’s knowledge base

