Skip to content

Commit b88964e

Browse files
yayualtaywtf
authored andcommitted
fix(cron): forward abort signal into runWithModelFallback
Thread the cron executor's abort signal into the shared runWithModelFallback call so that cron timeouts and cancellations stop the fallback chain instead of retrying with the next candidate. Previously, the run callback checked params.abortSignal?.aborted and threw, but runWithModelFallback itself had no signal — so the new guard in model-fallback.ts could not distinguish a caller abort from a provider-side AbortError and would retry silently. Also adds a focused regression test verifying the signal is forwarded.
1 parent 722f992 commit b88964e

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

src/cron/isolated-agent/run-executor.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ export function createCronPromptExecutor(params: {
283283
agentDir: params.agentDir,
284284
agentId: params.agentId,
285285
sessionKey: params.runSessionKey,
286+
abortSignal: params.abortSignal,
286287
prepareAgentHarnessRuntime: async ({ provider, model, agentHarnessRuntimeOverride }) => {
287288
await ensureSelectedAgentHarnessPlugin({
288289
config: params.cfgWithAgentDefaults,

src/cron/isolated-agent/run.cron-model-override-forwarding.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,4 +665,21 @@ describe("runCronIsolatedAgentTurn — cron model override forwarding (#58065)",
665665

666666
expect(capturedFallbacksOverride).toEqual(["openai/gpt-4o"]);
667667
});
668+
669+
it("forwards the cron abort signal into runWithModelFallback", async () => {
670+
const controller = new AbortController();
671+
let capturedAbortSignal: AbortSignal | undefined;
672+
runWithModelFallbackMock.mockImplementation(
673+
async (params: { provider: string; model: string; abortSignal?: AbortSignal }) => {
674+
capturedAbortSignal = params.abortSignal;
675+
return makeSuccessfulRunResult();
676+
},
677+
);
678+
679+
controller.abort(new Error("cron: job execution timed out"));
680+
681+
await runCronIsolatedAgentTurn(makeParams({ abortSignal: controller.signal }));
682+
683+
expect(capturedAbortSignal).toBe(controller.signal);
684+
});
668685
});

0 commit comments

Comments
 (0)