Skip to content

Reports: AI executive summary misreads mentions/citations % change as absolute counts #514

Closed

Description

@d180

Problem

InsightsSummary.mentionsChange and InsightsSummary.citationsChange (web/src/lib/actions/tracking.ts) are percentage deltas vs. the previous period of equal length — e.g. 1262 means "+1262%", matching how the KPI card renders it (+1262%, see the Delta component's % suffix in both the report viewer and PDF).

The report's AI executive summary (server/src/routes/reports.js, POST /api/reports/summary) receives the raw JSON snapshot and narrates these fields as if they were absolute counts. Example output for a report where totalMentions: 354 and mentionsChange: 1262:

"total mentions increasing by 1,262 to reach 354"

That's nonsensical — a literal reading implies a previous value of 354 - 1262 = -908, which is impossible. The same happened with citations (totalCitations: 177, described as "citations climbing by 1,080, totaling 177").

Found while verifying #492 — unrelated to that fix (which only concerns the visibility-rate headline metric), but real and reproducible with any report whose mentions/citations grew a lot from a small prior base.

Fix

In SUMMARY_SYSTEM_PROMPT (server/src/routes/reports.js), clarify that mentionsChange/citationsChange (and any other *Change field sourced from getInsightsSummary) are percentage deltas, not absolute counts, and instruct the model to phrase them accordingly (e.g. "mentions rose 1,262%, to 354" rather than "increased by 1,262 to reach 354").

Acceptance criteria

  • Regenerating a report where mentions/citations grew sharply from a small base produces a summary that states the change as a percentage, consistent with the KPI card's +X% display, and never implies an impossible previous value.

Activity

  1. added
    bug
    good first issue
    help wanted
    on Jul 23, 2026
  2. gkhngyk commented on Jul 23, 2026

    @gkhngyk
    Contributor

    Confirmed — the math in the example checks out (prev ≈ 26 → 354 is +1,262%), and the system prompt indeed never states these fields are percentages. Good catch and a well-scoped fix.

    One nuance to fold into the prompt wording: the *Change fields are not always percentages. getInsightsSummary falls back to an absolute difference when either window is zero (curMentions > 0 && prevMentions > 0 ? pct : curMentions - prevMentions in web/src/lib/actions/tracking.ts), so a brand going 0 → 354 gets mentionsChange: 354 meaning "+354 mentions", not "+354%". The prompt should say the fields are percentage deltas except when growth starts from zero, and tell the model not to assert a unit it can't verify in that case.

    The root cause (mixed-semantics field + the KPI card unconditionally rendering a % suffix, which mislabels the zero-base case in the UI too) is now tracked separately in #520 — this issue stays scoped to the summary prompt.

  3. gkhngyk commented on Jul 24, 2026

    @gkhngyk
    Contributor

    Resolved by #521 — the report summary system prompt now states that mentionsChange/citationsChange are percentage deltas, never raw counts. The snapshot also carries prevMentions/prevCitations now, so zero-base growth is described as "N new mentions" instead of an impossible percentage.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issuehelp wanted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions