fix(eval): cancel queued provider-eval jobs when a standalone evaluation is deleted#247
Open
tryeverything24 wants to merge 1 commit into
Open
Conversation
DELETE /api/admin/evaluations/{id} soft-deleted a standalone provider
evaluation but left its provider_eval row in job_queues untouched. The
worker only filters on JobQueue.status == "queued" and never checks
EvaluationRun.deleted_at, so an eval deleted before it ran would still
be claimed, executed, and charged real provider spend -- then complete
while hidden from /api/provider-benchmarks. The submission delete path
already guards this via cancel_submission_jobs; add the equivalent
cancel_evaluation_jobs and call it from admin_delete_evaluation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Deleting a standalone provider evaluation from the admin UI now also cancels its
still-queued job, so a "deleted" eval can no longer be picked up and executed by a
worker.
Why
DELETE /api/admin/evaluations/{id}soft-deletes a standalone provider evaluation bysetting
deleted_at, but it left the evaluation'sprovider_evalrow injob_queuesuntouched. The worker's poll query (
worker.process_once) only filters onJobQueue.status == "queued"and never looks atEvaluationRun.deleted_at, so aprovider eval that was deleted before it ran would still be claimed, executed via
evaluate_provider_route(...), and charged real provider spend — the exact outcome anoperator is trying to avoid by deleting it. The run then completes while remaining
hidden from
/api/provider-benchmarks(which filters ondeleted_at), so the wastedcost is also invisible.
The submission delete path already guards against this:
DELETE /api/admin/submissions/{id}calls
cancel_submission_jobs(...). Standalone-evaluation delete was simply missing theequivalent step.
Change
cancel_evaluation_jobs(session, evaluation_id, reason=...)inservices/queue.py, mirroringcancel_submission_jobs: it flips anyqueuedprovider_evaljob for that evaluation id tocancelled(arunningjob is leftalone, matching the submission path).
admin_delete_evaluationright after settingdeleted_at, before thecommit, so the soft-delete and the cancellation land in one transaction.
Revoke behaviour is unchanged; only the queued job is affected, and only on delete.
Tests
Adds
validator/tests/test_delete_evaluation.py:provider_evaljob (RED before the fix:the job stayed
queued),Verification
python -m pytest -q(validator suite) green against Postgres 16.ruff check .clean invalidator/.