Skip to content

fix(viewer): do not start the AI comparison at page load - #741

Open
omkargaikwad23 wants to merge 3 commits into
mainfrom
fix/viewer-compare-on-click
Open

omkargaikwad23 wants to merge 3 commits into
mainfrom
fix/viewer-compare-on-click

Conversation

@omkargaikwad23

@omkargaikwad23 omkargaikwad23 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

What

  • A page load with a compare link opens the Compare tab and selects the two runs. It does not call the model. A new button, "Run AI comparison", starts the comparison.
  • compare_evals stores each result in memory, 64 entries for each server process. The key has the two run IDs and the modification time and size of the run files, so a changed run gets a new comparison. An error is not stored.
  • compare_evals does not read a run file that is larger than 100 MB. It returns an error message.

Why

  • A link with ?tab=compare&eval1=...&eval2=... started the AI comparison during the page load. Each open of the link made a model call and held a server worker until the answer came.
  • The viewer did not store the result, so the same two runs gave a new model call each time.
  • The comparison read the complete evals.csv and scores.csv files, with no size limit.

Behavior change: a shared compare link needs one click on "Run AI comparison" before the AI text shows. A run with an evals.csv or scores.csv above 100 MB gets an error message in place of the AI comparison.

Testing

  • viewer_ai_comparer_test.py: 5 tests pass. With 7 related test files: 156 tests pass. pycodestyle is clean.
  • .ci/verify_viewer.py has a new check: on_load with a compare link must not call compare_evals, and the page must show the button. With the viewer code of main, the check fails. With this PR, the script passes.
  • The button path, with a stub in place of the model:
Step Result
Page load with a compare link 0 model calls. The page shows the button
Click on the button 1 model call. The page shows "Comparing...", then the AI text
Second click Still 1 model call
  • Real check with the real model (gemini-2.5-flash) on two real result folders. Request 1 takes 12.2 s and makes 1 model call. Request 2 takes 0.0 s and makes no model call.

Logs (Google-internal): https://paste.googleplex.com/6755399437648066

A link with ?tab=compare&eval1=...&eval2=... started the AI comparison
in on_load. Each open of the link made a model call and held a server
worker until the answer came.

on_load now only opens the Compare tab and selects the two runs. A new
button on the tab starts the comparison.

compare_evals stores each result in memory. The key has the run IDs and
the state of the run files, so a changed run gets a new comparison. It
also refuses a run file that is larger than 100 MB.
@omkargaikwad23
omkargaikwad23 marked this pull request as ready for review November 26, 2026 08:24
omkargaikwad23 and others added 2 commits November 26, 2026 08:29
compare_evals called os.path.exists and os.path.getsize for the size
check, and os.stat for the cache key. A file that disappeared between
the calls raised an error. The size check now uses the same file state
as the cache key.
@omkargaikwad23

Copy link
Copy Markdown
Collaborator Author

/gcbrun

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