Skip to content

Concepts

The assistant is a plain tool loop on the Anthropic SDK: no agent framework, no vector store. The models decide what to ask; deterministic code decides what may run and what it may cost.

flowchart LR
    Q[Question] --> G{Guards}
    G -->|ok| A[Analyst]
    A -->|search_docs| P[(Pages, BM25)]
    P -->|passages with URLs| A
    A -->|list_tables / describe_table| M[(Schema only)]
    A -->|run_sql| C{Deterministic checks}
    C -->|ok| R[SQL reviewer agent]
    R -->|approved| D[(DuckDB, read-only)]
    D -->|rows| A
    A --> Ans[Answer with its queries and cited pages]

Modes

The mode is part of the Domain and is never guessed from the database.

Mode Answers from Typical use
data_and_docs Tables and pages A product's public Q&A, like RetroSpeedLab's Ask me anything
docs Pages only; politely declines data questions A company website chat
data Tables only An internal data desk

The analyst only gets the tools of its mode, so a docs-only chat cannot even ask for a table.

Two agents for the data

The analyst sees metadata only: table and column descriptions and keys, never rows. It writes one DuckDB SELECT and calls run_sql. Before the query runs, the reviewer, a second Claude call with a structured verdict, checks it against the question and the schema: wrong joins, mixed units, columns that do not exist, and the mistakes your review_rules name. A rejection goes back to the analyst as feedback, and it tries again within max_queries.

The reviewer catches wrong SQL. It is not the safety boundary.

The SQL boundary

Every query passes deterministic checks that hold whatever either model does:

  • One SELECT. DuckDB's own parser rejects DDL, DML, COPY, ATTACH, SET, INSTALL and multiple statements.
  • An allowlist. The syntax tree may reference only the file's own tables in the main schema and its own CTEs, and no table function except range, generate_series and unnest. System tables, file readers and the docs index stay out of reach.
  • A sandbox. The file is opened read-only with external access off, extension autoloading off, 1 GB of memory, 2 threads and a locked configuration, so a query cannot loosen any of it.
  • Runtime bounds. A 20 second deadline, at most 200 rows and 8,000 characters of SQL.

Docs search with citations

New in 0.4.0. index_docs splits each Markdown page at its headings into passages with the page title, heading, URL and text, and builds a BM25 full-text index with DuckDB's fts extension in a docs schema of the same file. The search_docs tool returns at most 5 passages of up to 2,000 characters, and the analyst cites every page it uses as a link.

Pages are public text, so searches skip the reviewer; they still count against max_model_rounds. BM25 matches words, not meaning: when nothing matches, the analyst searches once more with other words and otherwise says it does not know.

Grounding

The system prompt allows answers only from what the tools returned. Query results, schema descriptions and passages are treated as data, never as instructions, and the assistant stays on the domain you describe. Prompt injection can still change which SELECT the analyst writes; the boundary above limits what that query can do.

The guards

GuardedAnalyst answers before the model does, so a refused question costs nothing. In order:

  1. Question check: empty and over-long questions.
  2. Answer cache: the same question, ignoring case and spacing, is paid for once; only complete answers are kept.
  3. Rate limit per asker: a moving window per visitor or chat user.
  4. Rate limit per network (0.4.0): per IPv4 /24 or IPv6 /64, so one host rotating addresses keeps its limit.
  5. Burst cap (0.4.0): everyone's questions per minute together, against floods from many askers.
  6. Daily budget: a hard USD limit per UTC day that survives restarts. Since 0.4.0 it is released in 24 hourly shares that roll forward within the day, so a flood spends only what has been released. Each question reserves its whole answer budget first, so parallel questions cannot pass the limit together.

The limits count from the narrowest out, so one asker over their own limit uses up nobody else's share. Inside each answer, Limits caps the model rounds, the reviewed queries and the answer's cost, and Models refuses a model without a known price, so every budget can be enforced.

The full list with what each guard stops is in the README; the threat model is in SECURITY.md.