Skip to content

fix: rename citation precision/recall to inclusion; report real cached-token counts - #4

Merged
ahmedEid1 merged 2 commits into
masterfrom
fix/metric-names-cache-tokens
Oct 30, 2026
Merged

ahmedEid1 merged 2 commits into
masterfrom
fix/metric-names-cache-tokens

Conversation

@ahmedEid1

Copy link
Copy Markdown
Owner

Two honesty fixes.

1. "Citation precision" measures paper selection (O06)

citationPrecision / citationRecall (lib/eval/metrics.ts, called from scripts/run-evals.ts) compare the paper ids a run includes with the golden's expectedPapers. They never look at the citations in the draft. The README said "the citations it does surface are accurate — citation precision 97%".

Changes:

  • /evals dashboard: labels are now "Inclusion recall" / "Inclusion precision"; the descriptions and formulas say "included" instead of "cited"; the precision definition says it does not check the draft's citations and is 100% by construction when a golden's corpus has no distractor papers. The headline banner says what is measured.
  • README: the cite_check bullet no longer attributes 97% / 74% to citation accuracy. It says the papers Thoth includes are compared with each question's expected list, that this is not a check of citations, and links to the new limitations section. The Proof row and the dashboard description use the new names. The screenshot alt text notes the screenshot still shows the old labels.
  • evals/README.md: new "Known limitations" section. 7 of the 17 V1 goldens (000, 004, 007, 008, 014, 015, 016) seed no distractor papers, so inclusion precision is 1.0 by construction on those (checked by comparing papers[].id with expectedPapers in every evals/golden/*.yaml).
  • Stored metric keys (citation_recall, citation_precision) in the DB, eval-results.json and the regression script are unchanged. metrics.ts gets doc comments noting the display names.

Number of goldens behind 97% / 74%: the README previously placed these figures next to "7 of 18 populated at this commit". The committed screenshot docs/assets/media/03-evals.png, which shows the same 97% / 74%, lists 9 V1 goldens with a precision/recall score (000, 001, 002, 004, 005, 007, 008, 009, 010). Their per-question values average to 97% and 74%. The "7 of 18" is the dashboard's "goldens with data at the latest commit" badge. The README now says the figures are averaged over 9 goldens, and "populated at this commit" now reads "have data at the latest sweep's commit". Four of those 9 (000, 004, 007, 008) have no distractor papers. The live dashboard currently returns 500 (database down), so these numbers come from the screenshot and could not be checked live.

2. Cached input tokens were always 0 (O10)

runLLM returned cacheReadInputTokens: 0 on every path. In ai@6.0.191, generateObject returns usage.inputTokenDetails.cacheReadTokens, and each provider package fills it from its own field. Checked in the installed packages:

  • @ai-sdk/anthropic: cache_read_input_tokens
  • @ai-sdk/openai: prompt_tokens_details.cached_tokens (chat) / input_tokens_details.cached_tokens (responses)
  • @ai-sdk/mistral: num_cached_tokens, falling back to prompt_tokens_details.cached_tokens
  • @ai-sdk/google: cachedContentTokenCount
  • @ai-sdk/groq: always unset

runLLM now reads that field and defaults to 0. The claude-agent path still returns 0 because it reports no per-call usage. This change adds no prompt caching, and the repo sets no cache_control. This was the smaller option: removing the field would have touched the RunStep column, two UI components and about a dozen test files.

The AI SDK counts cached tokens inside inputTokens. The token badge's doc comment said cache reads are not counted toward the budget, which is wrong once real values come through, so the comment is corrected. Budget behaviour is unchanged.

Verification

  • pnpm typecheck: clean
  • pnpm lint: clean
  • pnpm test: 95 files passed, 1 skipped; 691 tests passed, 2 skipped. Includes 2 new runLLM tests for the cached-token mapping.
  • Not run: e2e/live tests and evals (no database). The /evals page change was typechecked but not rendered. I have not seen a non-zero cached-token value from a real provider.

🤖 Generated with Claude Code

ahmedEid1 and others added 2 commits October 30, 2026 01:24
…ecall

The metric compares the papers a run includes with each golden's
expectedPapers; it never looks at the citations in the draft. The README
presented it as "the citations it does surface are accurate".

- Dashboard labels, descriptions and formulas now say "Inclusion
  recall/precision" and "included" instead of "cited". Stored metric keys
  (citation_recall / citation_precision) are unchanged.
- README: the cite_check bullet no longer attributes 97%/74% to citation
  accuracy; it says what is measured and that the figure is averaged over
  the 9 goldens with an inclusion score (per the committed /evals
  screenshot), and points to the limitations.
- evals/README.md: new "Known limitations" section. 7 of the 17 V1
  goldens (000, 004, 007, 008, 014, 015, 016) seed no distractor papers,
  so inclusion precision is 1.0 by construction on those.
- metrics.ts: doc comments on citationRecall/citationPrecision.
- live e2e smoke regex matches the new label.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-coded 0

runLLM returned cacheReadInputTokens: 0 on every path. The AI SDK (ai 6)
already maps each provider's cached-token field into
usage.inputTokenDetails.cacheReadTokens (Anthropic cache_read_input_tokens,
OpenAI prompt_tokens_details / input_tokens_details.cached_tokens, Mistral
num_cached_tokens, Gemini cachedContentTokenCount; Groq leaves it unset), so
read it from there, defaulting to 0. The claude-agent path still reports 0
because it has no per-call usage.

No prompt caching is added; Thoth sets no cache_control. The value is a
subset of inputTokens, so the token-badge comment that said cache reads are
not counted toward the budget is corrected. Adds two unit tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Oct 30, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
thoth Error Error Oct 30, 2026 12:24am UTC

@coderabbitai

coderabbitai Bot commented Oct 30, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1697c1d3-33c5-4831-8598-8ffa876c864d
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@ahmedEid1
ahmedEid1 merged commit ab60276 into master Oct 30, 2026
4 of 5 checks passed
@ahmedEid1
ahmedEid1 deleted the fix/metric-names-cache-tokens branch October 30, 2026 00:27

This branch had an error being deployed

1 failed deployment
Preview — 66791d1f Deployed Oct 30, 2026 by vercel[bot]
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