The AI notebook agent

fonctionnel

AI cells that plan, build, investigate and review with labelled evidence, budgets and consent, and the things the agent can never do.

An AI investigate cell's findings, each labelled Observed fact, Derived metric, Hypothesis or Recommendation with buttons to its evidence, its budget, and a build cell whose proposals go in only when approved, with a DELETE refused outright. The answers are a saved run of a local model.

Real recording · saved AI run (local qwen2.5-coder) · Northwind demo data

Open the walkthrough on its own page

Une IA cell asks SQLly's notebook agent a question about the notebook: why a query failed, how to investigate a number, whether a join double-counts. The agent reads the notebook, can run a few read-only queries within a budget you can see, and answers with findings that each say what they rest on. It never edits the notebook directly: everything it wants to change is a proposal you accept or reject.

AI cells use the AI provider you set up for the rest of SQLly. A local model (Ollama, MLX) runs straight away; a cloud model asks first and shows exactly what it will send (see below).

Modes

Add an AI cell, type a question ("Ask about this notebook: explain, plan, build, investigate or review…"), pick a mode and press Exécuter.

ModeCe que cela faitCan queryDefault budget
AssistExplain an error, complete or fix SQL, suggest a chart or read a plan. Proposes cells and edits.Oui3 queries, 1,000 rows, 30 s of query time, 8 turns
PlanWrites an investigation plan for you to review: goal, steps, sources, assumptions, cost and safety concerns, permissions needed. Nothing runs.NonNo queries, 8 turns
ConstruireTurns the request (or an approved plan) into proposed cells, edits and runs.NonNo queries, 8 turns
InvestigateRuns a few read-only queries, iterates, and reports findings with evidence. Can propose cells and runs.Oui8 queries, 5,000 rows, 60 s, 12 turns
RevueSQLly's own checks run first, then the model reviews the SQL and can propose edits.Oui4 queries, 2,000 rows, 60 s, 12 turns
Explain changesSays what changed between two points, and why: SQL, settings, parameters, connection or sign-in, an input cell, or the data. By default it compares with the last time the AI cell read each cell; two pickers ("Compare the last time this cell ran / the run of …" and "with now / the run of …") compare any two runs from the notebook's run history, or a past run with now.NonNo queries, 8 turns

Every mode also has a 40,000-token budget. In Plan, the answer becomes a reviewable plan with "Nothing runs until you approve." and Approve and build, which switches the cell to Build with the plan attached.

SQLly
AI cell showing an investigation plan and the Approve and build buttonAI cell showing an investigation plan and the Approve and build button
An AI cell in Plan mode: an investigation plan with goal, steps, sources and assumptions, waiting for approval.

A failed SQL cell offers Explain with AI under its error: it adds an Assist cell below, aimed at the failed cell, and runs it. Explain Last Error on a notebook tab does the same for the notebook's failed cell. Plan cells have an Explain with AI button too, which asks which steps of the plan cost the most, why, and what would make the query faster.

SQLly
Failed SQL cell with Explain with AI and an Assist answerFailed SQL cell with Explain with AI and an Assist answer
A failed SQL cell's Explain with AI, with the Assist cell's answer and proposed fix below it.

Findings and evidence

Every finding is labelled:

Observed fact
Something a result shows directly.
Derived metric
A number worked out from results.
Hypothesis
A possible explanation, not proven.
Recommendation
Something to do next.

Each finding links to its evidence: a cell and the run it read ("by_country · run 3f2a…"), or a query the agent ran ("query q1"). SQLly, not the model, decides whether a finding is verified. It is marked Unverified, with the reason, when nothing was run, it cites no evidence, it cites a result the agent didn't read, the value it quotes isn't in its evidence, or it rests on sampled or partial data (or a query cut at its row limit). Two findings that give different values for the same thing are both kept and marked "Contradicted by …". The same labels appear in exported reports.

SQLly
AI cell findings labelled with evidenceAI cell findings labelled with evidence
An Investigate run's findings: observed fact, derived metric, hypothesis and recommendation, with evidence links, an unverified finding and a contradiction.

Review: SQLly's checks first

In Review mode, before the model sees anything, SQLly checks each query itself and shows the results as "SQLly check: …": totals inflated by a join that repeats rows (a fanout join, such as SUM(o.Freight) across orders joined to order lines, confirmed from the cell's own results when the join key repeats), COUNT(*) over joins, SUM ou AVG de DISTINCT, out-of-date or reused results, sampled or partial data, cells that skip a filter the rest of the notebook applies, server-clock functions such as GETDATE() et NOW(), cells allowed to change data, and sensitive-looking columns.

SQLly
AI cell in Review mode with SQLly check findingsAI cell in Review mode with SQLly check findings
Review mode: SQLly's own checks (a fanout join with its fix) listed before the model's review.

Proposals you approve

  1. Proposals are listed under the answer: "Insert 3 cells after by_country", "Edit orders" (with a line diff), "Run by_country".
  2. Accept ou Reject each one.
  3. Apply accepted (2) applies them as one group. New cells start read-only and carry an IA badge ("from investigate_freight"); they're ordinary cells you can edit. Accepted runs go through the normal run path and its checks.
  4. Undo AI changes reverses the whole group in one step.

The agent can propose every kind of cell it can describe, including plan and entity detail cells. Each proposal is checked again when you apply it. Anything that would change data, edit a cell that's allowed to change data, edit the AI cell itself, move a cell somewhere else to run (onto local data or another connection: "Refused: the new settings would change where orders runs. Only you can do that."), or doesn't fit the cell kind's settings is shown as "Refused by SQLly" with the reason. A proposal that changes a cell's settings, not just its SQL, shows those settings changes in its diff.

SQLly
AI cell proposals with Accept, Reject and a refusalAI cell proposals with Accept, Reject and a refusal
Build mode: proposed changes with Accept and Reject, a line diff for an edit, and a refused DELETE.

Budgets

The cell's Budget meter shows queries, rows, query time, tokens and turns used against their limits ("Queries 2 of 8"). Limits are checked before each step; a query's row limit is cut to what's left, and once a budget is spent the agent is told to finish. Arrêter ends a run at any time. Run again reruns the cell; Run All passes over AI cells without starting a model.

To see what a cloud run costs, type your provider's prices in Settings ▸ AI on the cloud profile: Price per 1,000 input tokens (USD) et Price per 1,000 output tokens (USD). They're optional, and SQLly never looks them up. With prices set, the meter shows "Estimated cost $0.04", or "Cost $0.04 of $0.50" when the cell has a cost cap (max_cost_usd in the cell's budget, up to $100), and the run stops at the cap ("Stopped: the cost cap was reached"). Without prices, a cell with a cap says "Cost cap $0.50 not applied: set this provider's prices in Settings → AI". Local models have no price.

SQLly
AI cell budget meter showing an estimated costAI cell budget meter showing an estimated cost
An AI cell's budget meter with the estimated cost of the run worked out from the provider's prices.
SQLly
AI cell budget meterAI cell budget meter
The top of an AI cell: mode buttons, the prompt, Run again, the model line and the budget meter.

Cloud models and consent

With a cloud model, the first run in a notebook stops at "Share this notebook's context with …?" and shows exactly what the first request will send (your request, the instructions, the notebook outline, the cell it's about, SQLly's check results), how many rows and queries the agent's tools may add later, and a Never sent list: connection credentials and anything that looks like a password, key or token, the values of sensitive parameters, and the values of sensitive-looking columns (also when the query renames them with an alias). Nothing leaves your computer until you press Share and run. That consent is kept for this notebook and provider on this computer only, never in the file.

SQLly
AI consent preview with the Never sent list and Share and runAI consent preview with the Never sent list and Share and run
Before a cloud model is used, the AI cell previews exactly what is sent and what never is.

What the agent can never do

  • Write. There is no tool that changes data, and every query it runs must be a SELECT for that connection's engine, on a read-only session.
  • Export or reach the network. There is no export, send or HTTP tool; a request for one is answered "Unknown tool".
  • Pick its own connections. It can query only the notebook's connections that your trust allows (and that the production read lock doesn't block), whatever text in a cell or a result says.
  • Gain permissions from your data. What it may do comes from SQLly's own code and your trust, never from text it reads. Cell text, errors, column names and sample rows reach the model fenced off as data, with invisible characters removed and the fence markers defused, which makes it harder for planted text to steer the model, but can't rule it out. That's why findings carry evidence SQLly checks, and every change waits for your approval.
  • Change the notebook behind your back. Every change is a proposal, checked again when applied, and undoable.

Each run is recorded in a local action log (SQLLY/notebooks/ai/, readable only by you): the mode, provider and model, the tools it was offered, each tool call and query with hashes of its arguments and results, the budget used, and your approvals. Prompts and data are not written, only their hashes.

Limites

  • The agent can read through production connections, as SQLly's other AI features can, unless the production read lock is on. It can never write to them.
  • Token counts, and so costs, are estimates. A cost cap is set in the cell's settings in the file; there's no field for it in the cell yet.
  • Undo AI changes is kept for the tab's session; it doesn't survive a restart.
  • The run pickers in Explain changes list the runs the History tab loads (the newest 200).
  • The action log isn't shown in the app yet.
  • The fanout check relies on key names (id, CustomerID, customer_id) and qualified columns; the ambiguous-term check knows English terms only.
  • AI cells run in the desktop app only.