Skip to content

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

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

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

Conversation

@omkargaikwad23

@omkargaikwad23 omkargaikwad23 commented Nov 26, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

  • 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.

Change

  • The page load 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.

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.

Tests

  • 4 new tests in viewer_ai_comparer_test.py for the stored result and the size limit.
  • .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.
.ci/verify_viewer.py Before After
on_load with a compare link Fails: started the AI comparison Pass
All other checks Pass Pass
  • The button path, in a local run 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

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
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.
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