Skip to content

fix(dataset): reset QA training jobs after the agent model is saved - #7918

Closed
irontaek wants to merge 1 commit into
labring:mainfrom
irontaek:fix/dataset-update-training-reset
Closed

irontaek wants to merge 1 commit into
labring:mainfrom
irontaek:fix/dataset-update-training-reset

Conversation

@irontaek

@irontaek irontaek commented Oct 8, 2026

Copy link
Copy Markdown

Problem

POST /api/core/dataset/update resets the lock of the dataset's QA/auto training jobs when the agent model changes, so that they are retried with the new model. However, the reset (updateTraining) has two problems:

  • It runs before the update is committed. It is called before mongoSessionRun(onUpdate) writes the new agentModelId. The QA worker reads the dataset's agent model when it picks a job (generateQA.ts, getDatasetModelReference(data.dataset, 'agent')), so a worker can pick a released job while the dataset still points at the old model.
  • It is not awaited. If the updateMany fails, the error becomes an unhandled rejection instead of failing the request.

Fix

Move the reset after mongoSessionRun and await it. The jobs are released only once the new model is committed. If the update transaction throws, they are not released at all.

Test

test/api/core/dataset/update.test.ts gets a new case, "releases QA training jobs only after the new agent model is stored". It spies on MongoDatasetTraining.updateMany and records the dataset's stored agentModelId at the moment the reset runs.

  • Before the fix, it fails: expected [ 'original-agent' ] to deeply equal [ '<new model id>' ].
  • After the fix, it passes.

npx vitest run -c vitest.config.ts test/api/core/dataset/ in projects/app: 37 files, 194 tests pass.

https://claude.ai/code/session_01W9Mk18mBNfkPfgg3hYweKq

Changing a dataset's agent model resets the lock of its QA/auto training
jobs so they are retried with the new model. The reset was fired without
await and before the dataset update transaction ran, so a worker could
pick a released job while the dataset still pointed at the old model,
and a failed reset became an unhandled rejection.

Run the reset after mongoSessionRun commits, and await it.

Claude-Session: https://claude.ai/code/session_01W9Mk18mBNfkPfgg3hYweKq
@cla-assistant

cla-assistant Bot commented Oct 8, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@c121914yu

Copy link
Copy Markdown
Collaborator

This is a catch-all mechanism that does not require strict await and meets expectations. The new version has removed this update and will no longer automatically refresh and retry

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants