Repository navigation
fix(scheduler): count a run only when it ends - #7659
Conversation
A task card showed 'Runs: 1, Last: just now' while the run was still going, and a run that then failed was already counted. The count and last-run time now change when the run finishes. Closes amd#7613
|
Verdict: Request changes The fix is right: a schedule's run count and "Last" time no longer change at the moment a run starts. They now change when the run finishes, and a run killed mid-way isn't counted. One gap remains. The card publishes the time at the end of the run but still stamps it with the time the run started, so for any real model run it looks stale the moment it lands:
Stamping the finish time instead is a one-line change (suggestion below). Real-world evidenceN/A: no evidence bundle was produced for this run. The PR shows a "before" screenshot. Its own real-app test-plan item ("Runs: 0 until the run ends, then Runs: 1, Last: just now") is still unchecked, and that is the step that would have caught the issue above. Apart from that screenshot, this verdict rests on reading the code. 🔍 Technical details🟡
Keep A test that runs the fake executor past a patched clock (or asserts Checked, no issue:
Strengths
|
Scheduled tasks run while the user is away, but when one finished nothing told them; only failures reached the bell. Now a run that finishes cleanly adds an unread "Scheduled task "<name>" finished" notification with the start of the answer. Runs that were already done when the app opened stay quiet, and a failed run still raises only its error. Closes amd#7596 | Before | After | | --- | --- | | <img src="https://raw.githubusercontent.com/tylerbea/gaia/pr-shots/7596/before.jpg" width="420"> | <img src="https://raw.githubusercontent.com/tylerbea/gaia/pr-shots/7596/after.png" width="420"> | ## Test plan - [x] New `stores/__tests__/scheduleStore.finished.test.ts` (3 of 5 cases fail on main), plus all store and i18n tests (192) and `npm run build` - [x] Built app with the schedule list stubbed to a finished run: the bell shows 1 unread with the finished notice - [ ] With a real model: Run now on a task, close the dialog, and see the notice arrive when it ends <details> <summary>🔍 Technical details</summary> - `scheduleStore.ts` keeps finished-run counts per schedule (`run_count` minus a run in flight, since the backend counts a run when it starts) and compares them on each load, the same way it already compared error counts. - New string `schedules.finished` in English and Arabic. - Not in this change: clicking a bell item doesn't open its chat for any notification type. The notice carries the chat id, so that can follow in `NotificationCenter`. - The after shot stubs the schedule list and setup check, because the empty scratch home can't complete a real run. </details> Note: amd#7643 is the auto-fix bot's draft for the same issue. This one adds tests and before/after shots; keep whichever you prefer. amd#7659 changes when `run_count` goes up, so whichever merges second should recheck the finished-run count here.
The card publishes the count at the end of a run, so the time it shows must be the finish time too. With the start time, the just-ran highlight never showed for runs over 5 seconds and Last read minutes ago right after a long run finished.
Right after Run now, a scheduled task's card showed "Runs: 1, Last: just now" while it also said "Running…" and "No executions yet", and a run that then failed had already been counted. Now the run count and "Last" change when the run ends, together with its result.
Closes #7613
Test plan
test_run_is_not_counted_until_it_endsintests/unit/test_scheduler.py(fails on main with1 == 0), and the in-flight test now checks the count after the run🔍 Technical details
_execute_task_onceinscheduler.pyused to bumprun_countandlast_run_atbefore the turn ran. They now update after it, with the other result fields; the history divider and log lines use a localrun_number.