Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/backend/src/components/ai/system-prompt.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,13 @@ export function SystemPrompt({
an "exact" count based on the number of rows a limited query returned. To count rows, run a
separate query using COUNT(*) (or COUNT over a subquery) without a LIMIT/TOP clause.
</ListItem>,
<ListItem>
Table documentation files (columns.md, preview.md, ai_summary.md, how_to_use.md, ...) are for
understanding schema and semantics only. Their statistics (row counts, previews, aggregates) are
stale profiling snapshots — never present them as the answer to a data question. Any number you
present as an answer to a data question must come from a query executed in this conversation, or
be computed from such results.
</ListItem>,
...dialectSqlQueryRules,
]}
</List>
Expand Down
11 changes: 11 additions & 0 deletions apps/backend/tests/system-prompt.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,17 @@ describe('SystemPrompt built-in skills', () => {
});
});

describe('SystemPrompt SQL query rules', () => {
it('forbids citing table documentation statistics as answers to data questions', () => {
const markdown = renderToMarkdown(SystemPrompt({}));

expect(markdown).toContain('never present them as the answer to a data question');
expect(markdown).toContain(
'must come from a query executed in this conversation, or be computed from such results',
);
});
});

describe('SystemPrompt display_map rules', () => {
it('includes the display_map rule by default', () => {
expect(renderToMarkdown(SystemPrompt({}))).toContain('display_map');
Expand Down
Loading