使用 DSPy 评估和优化 Datasette Agent 的 SQL 系统提示词

Simon Willison 博客·2026-07-03 02:25·61天前·Simon Willison
AI 导读

Simon Willison 通过 Claude Code 中的异步研究任务(基于 Claude Fable 5)尝试用 DSPy 对 Datasette Agent 执行只读 SQL 查询时的系统提示词做评估与优化。Fable 选择测试 GPT 4.1 mini 和 nano,发现改进方向:模式列表仅给出表名,而“如果已有信息不要调用 describe_table”的建议导致列名猜测和错误重试循环。建议在提示词的模式列表中包含列名或软化该建议。

Simon Willison 博客
65AI 编辑部评分,满分 100

使用 DSPy 评估和优化 Datasette Agent 的 SQL 系统提示词

2026-07-03 02:25· 61天前· Simon Willison
AI 导读

Simon Willison 通过 Claude Code 中的异步研究任务(基于 Claude Fable 5)尝试用 DSPy 对 Datasette Agent 执行只读 SQL 查询时的系统提示词做评估与优化。Fable 选择测试 GPT 4.1 mini 和 nano,发现改进方向:模式列表仅给出表名,而“如果已有信息不要调用 describe_table”的建议导致列名猜测和错误重试循环。建议在提示词的模式列表中包含列名或软化该建议。

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

One of this morning's AIE keynotes covered dspy, which reminded me I've been meaning to see if it could help me improve the system prompt used by Datasette Agent - so I fired off an asynchronous research task in Claude Code for web using Claude Fable 5:

Pip install the latest Datasette alpha and datasette-agent and dspy - then figure out how to use dspy to evaluate and improve the main system prompts used by Datasette Agent for the feature where it can execute read only SQL queries to answer user questions about data.

Fable chose to test using GPT 4.1 mini and nano, and identified several promising looking directions for improvements. I particularly like this one:

The schema listing gives only table names; the "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 in baseline traces. Either include column names in the prompt's schema listing or soften that advice.

Tags: ai, datasette, generative-ai, llms, evals, dspy, datasette-agent, claude-mythos

来源:Simon Willison 博客· simonwillison.net