Using DSPy to evaluate and improve Datasette Agent's SQL system prompts

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Practitioners can now use DSPy as an automated harness to empirically find and fix flaws in production agent system prompts instead of hand-tuning them.

Read this as

Simon Willison used DSPy, a framework for testing and refining how AI systems are instructed, to improve the prompts behind Datasette Agent, a tool that answers questions about data using read-only SQL. He asked Claude Code to run the experiment, which tested with GPT 4.1 mini and nano. The evaluation found the prompt's schema listing omitted column names, causing the AI to guess them and loop on errors. Fixing this makes the agent's answers more reliable.

This is a working demonstration that prompt quality for AI agents can be measured and improved systematically rather than by guesswork, using DSPy against real tool calls on a live in-process Datasette. Teams maintaining agent products gain a repeatable evaluation method; those relying on intuition-driven prompt editing fall behind on reliability. The approach used GPT 4.1 mini and nano as test models, keeping evaluation costs low.

The harness invokes DSPy agents against Datasette Agent's actual tool implementations and prompts running on a live in-process Datasette, evaluated against an auto-generated gold-standard dataset with custom metrics. Testing GPT 4.1 mini and nano surfaced a concrete prompt flaw: the schema listing exposed table names only, while 'don't call describe_table if you already have the information' advice caused column-name guessing (page_count, o.order_id, first_name) and error-retry loops. Recommended fix: include column names in the schema listing or soften that advice.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

DSPy Datasette Agent Claude Code Pyodide AIE keynote

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading