---
title: "使用DSPy评估和改进Datasette Agent的SQL系统提示"
source: "Simon Willison 博客（Atom）"
source_tier: "t2"
url: "https://simonwillison.net/2026/Jul/2/dspy-datasette-agent-prompts/#atom-everything"
permalink: "https://feed.astralor.com/items/itm_38aa5ad2c12dd9a0f88601b0"
published: "2026-07-02T18:25:00.000Z"
score: 61
channel: "ai"
tags: ["Claude Code","Datasette Agent","DSPy","GPT-4.1","SQL提示优化"]
---

# 使用DSPy评估和改进Datasette Agent的SQL系统提示

## 速览

Simon Willison 在 AIE 主题演讲后，使用 Claude Code 和 DSPy 框架对 Datasette Agent 的 SQL 系统提示进行了自动化评估与改进实验。他选择 GPT-4.1 mini 和 nano 作为测试模型，发现了若干优化方向，其中最关键的是在系统提示的模式列表中加入列名，以避免因列名猜测而导致的错误重试循环。这项研究展示了 DSPy 在 AI 代理提示优化中的实际应用价值。

## 关键点

- 使用 DSPy 框架对 Datasette Agent 的系统提示进行自动化评估和优化。
- 实验选用 GPT-4.1 mini 和 nano 作为底层模型。
- 发现缺少列名描述导致模型猜测列名并陷入错误重试循环。
- 建议在提示的模式列表中明确包含列名以提升查询准确性。

## 全文

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

---

引用前请核对原文;本文由星际流动整理:https://feed.astralor.com/items/itm_38aa5ad2c12dd9a0f88601b0
