Skip to content

Commit 98b921d

Browse files
committed
fix: cancel other evaluation runs on fatal WCS error
Currently when there is a fatal error, e.g. in the executor (especially custom ones), WCS is aborting and "An error occurred" is printed, but the other kicked-off evaluations still run. This commit fixes this.
1 parent 123f7f9 commit 98b921d

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

runner/orchestration/generate.ts

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,11 @@ export async function generateCodeAndAssess(options: AssessmentConfig): Promise<
5858
// Ensure cleanup logic runs when the evaluation is aborted.
5959
options.abortSignal?.addEventListener('abort', cleanup);
6060

61-
const ratingLlm = await getRunnerByName('genkit');
62-
6361
await assertValidModelName(options.model, env.executor);
6462

63+
const ratingLlm = await getRunnerByName('genkit');
64+
const allTasksAbortCtrl = new AbortController();
65+
6566
try {
6667
const promptsToProcess = (
6768
await getCandidateExecutablePrompts(env, options.localMode, options.promptFilter)
@@ -129,7 +130,11 @@ export async function generateCodeAndAssess(options: AssessmentConfig): Promise<
129130
env,
130131
ratingLlm,
131132
rootPromptDef,
132-
combineAbortSignals(timeoutAbortSignal, options.abortSignal),
133+
combineAbortSignals(
134+
allTasksAbortCtrl.signal,
135+
timeoutAbortSignal,
136+
options.abortSignal,
137+
),
133138
workerConcurrencyQueue,
134139
progress,
135140
),
@@ -183,7 +188,7 @@ export async function generateCodeAndAssess(options: AssessmentConfig): Promise<
183188
const details = {
184189
summary: await prepareSummary(
185190
ratingLlm,
186-
new AbortController().signal, // Note: AI summarization is currently not abortable.
191+
allTasksAbortCtrl.signal,
187192
options.model,
188193
env,
189194
results,
@@ -211,6 +216,10 @@ export async function generateCodeAndAssess(options: AssessmentConfig): Promise<
211216
results,
212217
details,
213218
} satisfies RunInfo;
219+
} catch (e) {
220+
// Ensure all other running evaluations are cancelled.
221+
allTasksAbortCtrl.abort();
222+
throw e;
214223
} finally {
215224
await cleanup();
216225

0 commit comments

Comments
 (0)