Skip to content

List the datasets in the chat prompt and cache it - #182

Open
duaneatat wants to merge 5 commits into
mainfrom
db/chat-compact-dataset-list
Open

duaneatat wants to merge 5 commits into
mainfrom
db/chat-compact-dataset-list

Conversation

@duaneatat

@duaneatat duaneatat commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Cuts what the chat model reads and re-reads on every question. Includes the caching change from #183, which this replaces.

  • The dataset list moves from a list_datasets tool call into the instructions, ahead of the rules, built once at startup
  • The list is compact: about 20,000 characters instead of 73,000 (31 datasets). Shared caveats are stated once; none are dropped
  • Claude requests mark the tools, instructions and newest message as cacheable; usage reports cache_read_tokens and cache_write_tokens
  • If the warehouse can't be read at startup, the agent keeps the list_datasets tool. The MCP's tool is unchanged
  • Restart the API after replacing the warehouse so the listed year coverage is current

Eval (Haiku 5.5, 3 repeats, 15 chats, same warehouse; full entry in docs/reports/chat-eval-history.md):

  • Score 89% against 91% on main the same day; judge quality 7.4 against 7.5; no errors
  • Cost per chat $0.0039 against $0.0146 (down 73%); 13s against 16s
  • With the list at the end of the prompt instead, the score was 86%, hence the order
  • Limits case is lower (82% against 96%): the agent uses ACS population estimates where main uses the decennial series. Possible cause, untested: the list describes that series as having "206 missing years"
  • Rank case drew no chart in this run (3 of 3 on main); the rankings were correct

list_datasets returned about 73,000 characters for 31 datasets, and the
agent reads it on every later model request of a turn (often calling it
twice). Caveats shared by several datasets are now stated once, and
lineage and column plumbing are left to describe_dataset. The same
listing is about 20,000 characters. The MCP tool is unchanged.
One question is several model requests, each re-sending the tool
definitions, the instructions, and every earlier tool result. Mark all
three as cacheable through OpenRouter so later requests read them at
the cached rate. Other providers ignore the markers. The turn's usage
now reports cache read and write tokens.
Every question began with a list_datasets call, often two or three.
The compact list now sits at the end of the instructions, built once
at startup: that saves a model request per question, and the list is
part of the prefix Claude reads from cache on every request. If the
warehouse can't be read at startup the agent keeps the tool instead.
@duaneatat duaneatat changed the title Give the chat agent a compact dataset list List the datasets in the chat prompt and cache it Nov 12, 2026
With the list at the end, the rules for charts and answers sat ahead
of 20,000 characters of JSON. Three eval repeats scored 86% that way
and 89% with the rules last, at the same cost.
Three runs of Claude Haiku 5.5 on the current warehouse: main as a
same-day baseline, the list at the end of the instructions, and the
list ahead of the rules. List first scores 89% against main's 91% at
$0.0039 per chat instead of $0.0146.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant