Skip to content

fix: AI sees which rows it gets, and never guesses the others - #13

Merged
maxgfr merged 2 commits into
mainfrom
issue-12-anomaly-sample
Oct 16, 2026
Merged

maxgfr merged 2 commits into
mainfrom
issue-12-anomaly-sample

Conversation

@maxgfr

@maxgfr maxgfr commented Oct 16, 2026

Copy link
Copy Markdown
Owner

Closes #12

Anomaly detection sent the summary of all rows ("80 rows", group totals "computed on all 80 rows") and then only the first 50 under "Data to analyze", with "Analyze ALL rows provided". The model reported the sample as an anomaly: "le jeu de données annonce 80 lignes, mais seulement 50 sont fournies… les données semblent tronquées".

  • The rows now come under rows 1 to 50 of 80. The other 30 rows are left out on purpose; the summary above covers all 80. (or all N rows).
  • The system prompt says not to report row counts, missing/truncated rows or totals the sample does not add up to.

Data chat (same cause, worse result): it received the summary and 5 sample rows only, and the app passed no rows. Asked for EMP1060's salary and a count over 60 000 on 80 rows, Claude Sonnet 5.5 inferred a pattern from 5 rows and stated both numbers as fact.

  • askAboutData / streamAskAboutData send the rows as CSV: all of them, or the first ones within CHAT_ROWS_MAX_CHARS (20 000 characters, option maxRowChars), under the same kind of heading.
  • System prompt: whole-dataset totals from the summary, individual values only from the rows given, never infer or guess an unseen value; left-out rows are not truncation.
  • The app passes the analysed data to the chat.

Checks: lint, typecheck, csv-charts-ai 166 tests (4 new), app 103. Real model (Claude Sonnet 5.5, 80 rows): anomaly detection still finds the planted negative salary; the chat now answers EMP1060 = 66 220 and 22 employees above 60 000 by reading the rows (both match the data).

With more than 50 rows, anomaly detection sent a summary of all rows (80
rows, group totals on all 80) and then the first 50 under "Data to
analyze", asking to analyze all rows provided. The model reported the
sample itself: "the dataset announces 80 rows but only 50 are provided,
the data seems truncated". The rows now come under "rows 1 to 50 of 80,
left out on purpose", and the prompt says not to report row counts,
missing rows or totals the sample does not add up to.

Refs #12
…s them

The chat received only the summary and 5 sample rows, and the app passed
no rows at all. Asked for one employee's salary or a count over a
threshold, the model extrapolated a pattern from 5 rows and stated the
result as fact. The rows now go with the question (all of them, or the
first ones within 20,000 characters, under a heading saying which), and
the prompt says to take whole-dataset totals from the summary, individual
values only from the rows given, and never to guess a value it cannot see.

Refs #12
@maxgfr
maxgfr merged commit bd9a18b into main Oct 16, 2026
3 checks passed
github-actions Bot pushed a commit that referenced this pull request Oct 16, 2026
## [1.17.1](v1.17.0...v1.17.1) (2026-10-16)

### Bug Fixes

* AI sees which rows it gets, and never guesses the others ([#13](#13)) ([bd9a18b](bd9a18b)), closes [#12](#12)
@github-actions

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.17.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@maxgfr
maxgfr deleted the issue-12-anomaly-sample branch October 16, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Anomaly detection reports the 50-row sample as truncated data

1 participant