Skip to content

agentic-data-analyst

A robot detective at a desk answers a visitor's question from the bookshelf of docs and the database of data, while a second robot checks the answer and a coin jar keeps the costs

One assistant for your data and your docs: people ask in plain language and get answers they can check, at a cost you set.

  • Self-service answers. Customers, visitors and colleagues ask questions without a dashboard, a support ticket or database access.
  • Answers you can check. Every figure comes from a SQL query you can inspect, and every explanation links the page it came from.
  • No guessing. When neither the data nor the docs hold the answer, the assistant says so.
  • Safe by construction. Claude writes the SQL and a second agent reviews it, but deterministic code decides what runs: one read-only SELECT over an allowlist of tables.
  • Predictable cost. A cheap model, cached answers, rate limits per person and per network, a burst cap and a hard daily budget.
  • Nothing extra to host. The docs index lives in the same DuckDB file as the data: no embeddings, no vector store.

It runs RetroSpeedLab's Ask me anything in production.

Quickstart

uv add agentic-data-analyst
from pathlib import Path

import anthropic
from agentic_data_analyst import Analyst, Domain, Limits, Models, connect, index_docs, read_pages

database = Path("company.duckdb")
pages = read_pages(Path("site/pages"), lambda page: f"https://www.example.com/{page.with_suffix('.html').as_posix()}")
index_docs(database, pages, "porter")

analyst = Analyst(
    anthropic.AsyncAnthropic(),
    connect(database),
    Models(analyst="claude-haiku-5-5", analyst_effort="low", reviewer="claude-haiku-5-5", reviewer_effort="low"),
    Limits(max_question_chars=300, max_model_rounds=6, max_queries=3, answer_budget_usd=0.05),
    Domain(about="Example Ltd., a bakery chain", mode="docs", sql_rules=None, review_rules=None),
)
answer = await analyst.answer("When do your shops open on Sundays?")
print(answer.text)  # with links to the pages it used

This is a docs-only website chat. Getting started adds data tables and the guards for a public front end.

Where next

  • Concepts: the agents, the SQL boundary, the docs search and the guards.
  • Reference: every class and function an application imports.
  • README: the guards table, the demo chat and the limitations.