Simon Willison introduced Datasette Agent—an experiment that connects large language models (LLMs) to your datasets via Datasette. Here’s why it matters and a practical checklist to pilot it safely.
Source: Datasette Agent announcement by Simon Willison. Also see Datasette for background on the core data publishing platform.
What is Datasette Agent?
Datasette is a battle-tested way to publish and explore data (backed by SQLite) with fast JSON APIs. Datasette Agent extends that idea by giving an LLM “tools” to query your data through controlled endpoints—so the model can answer questions grounded in your actual tables, not just its training data.
Think of it as an AI-powered data concierge: the model proposes an action (e.g., filter rows, summarize a column), the system validates and runs it against Datasette, then returns structured results for the model to synthesize.
Why it matters now
- Grounded answers: Reduce hallucinations by forcing the model to use real, up-to-date data.
- Rapid prototyping: Datasette’s JSON endpoints make it easy to wire an agent without standing up a full data service.
- Governance: A gateway between LLMs and data enables logging, approvals, and allow-lists.
How to pilot safely (checklist)
- Start read-only: Expose only non-sensitive tables/columns and disable writes.
- Principle of least privilege: Create a dedicated Datasette instance with a minimal dataset for the pilot.
- Allow-list tools: Define a small set of permitted operations (e.g., top-N, date filters, aggregations) and block raw ad‑hoc SQL.
- Parameterized queries only: Never let the model compose raw SQL strings; use pre-defined, parameterized endpoints.
- Schema summaries: Provide the model with concise schema docs (table names, column types, join keys) to reduce guesswork.
- PII and secrets hygiene: Remove or mask sensitive fields; add automated checks before publishing.
- Transparent logs: Record the model’s prompts, tool calls, parameters, and results for audit and debugging.
- Human-in-the-loop: Require approval for high-impact queries and all first-time tool invocations.
- Red-team the prompts: Test prompt-injection attacks from user input and in-dataset content (CSV cells, text fields).
- Define success metrics: Track grounded accuracy, coverage (answerable vs. unanswerable), latency, and cost per answer.
Architecture sketch you can adapt
Expose a small, read-only Datasette instance with JSON endpoints for curated tables. Wrap those endpoints as “tools” your LLM can call (e.g., list recent rows, aggregate by date). The orchestrator validates parameters against an allow-list, forwards safe requests to Datasette, and returns compact JSON for the model to summarize. Cache stable results and paginate large responses to keep token costs in check.
Risks and mitigations
- Prompt injection: Strip/ignore instructions found inside dataset content; re-assert system rules on every tool call. See the OWASP Top 10 for LLM Applications.
- Over-permissioned access: Use dataset-level and column-level allow-lists; isolate environments per use case.
- Hallucinated queries: Constrain to pre-defined, parameterized queries and validate parameters against schema/enum sets.
- Data exfiltration: Monitor for unusually broad queries; rate-limit and require approvals for cross-table joins.
- Operational cost/latency: Batch queries, cache frequent results, and cap tokens per turn.
Who should try this
- Data teams: Internal Q&A over curated datasets and metrics definitions.
- Product teams: Embed grounded answers in user-facing help, docs, or analytics.
- Support/ops: Summaries and lookups for common investigative tasks.
Key takeaway
Datasette Agent is a promising path to give LLMs responsible, governed access to real data. Pilot with a narrow scope, strict allow-lists, strong logging, and clear success metrics.
Like content like this? Subscribe to our weekly newsletter for sharp, practical AI insights: theainuggets.com/newsletter.

