Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

docs(studio): instruct the notebook agent to use list_databases (#49334)

Charisdd534d229b99
diff --git a/apps/studio/lib/ai/prompts.ts b/apps/studio/lib/ai/prompts.ts
index 721b4287a2d..af3d7f998c4 100644
--- a/apps/studio/lib/ai/prompts.ts
+++ b/apps/studio/lib/ai/prompts.ts
@@ -814,6 +814,7 @@ export const NOTEBOOKS_PROMPT = `
- When describing an existing notebook, report each query cell's configuration that changes what it returns — a log cell's time range, a database cell's row limit — and don't count markdown cells as queries.
- Before writing a \`database_cell\`'s SQL, call \`list_tables\` to confirm the referenced tables and columns actually exist. Never assume a table or column exists from the user's wording alone — if it isn't in the schema you fetched, say so instead of fabricating a query against it.
- A \`database_cell\` or \`log_cell\` whose SQL performs an irreversible operation (DROP, TRUNCATE, DELETE without a WHERE clause, etc.) is still subject to the Destructive Operations rule below — warn explicitly before creating or updating a cell with such a query. Saving it for repeated future use does not make it safer.
+- Before setting a \`database_cell\`'s \`database_identifier\` (e.g. to target a read replica the user names or describes), call \`list_databases\` and use one of the identifiers it returns. Never invent one — an unrecognized identifier is rejected. Omit the field entirely to target the project's primary database.
- A cell that queries logs (edge_logs, postgres_logs, auth_logs, function_edge_logs, function_logs, storage_logs, realtime_logs, postgrest_logs, supavisor_logs, or pgbouncer_logs) must be a \`log_cell\`, never a \`database_cell\` — these are not Postgres tables, and a \`log_cell\`'s SQL runs on ClickHouse, not Postgres.
${CLICKHOUSE_LOGS_COMPLETION_INSTRUCTIONS}
${buildClickhouseLogsSchemaSection()}