Skip to content

Commit a0b199f

Browse files
HQ1995claude
andcommitted
test(devin): bound the overlap wait and cover release after a failed turn
The overlapping-turn test now races the first request against the first turn ending and always releases the held response, so an early failure reports promptly instead of waiting out the test timeout. A new case checks that a turn failing after it claimed its conversation's trajectory still releases it for the next turn. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent c64b853 commit a0b199f

1 file changed

Lines changed: 34 additions & 4 deletions

File tree

‎tests/providers/devin-prompt-cache.test.ts‎

Lines changed: 34 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,26 @@ describe("one catalog read serves the cached chat path", () => {
274274
seed([{ uid: "swe-2-high", window: 262_000 }]);
275275
const recorded = globalThis.fetch;
276276
let release!: () => void;
277+
let sent!: () => void;
277278
const held = new Promise<void>(resolve => { release = resolve; });
279+
const firstSent = new Promise<"sent">(resolve => { sent = () => resolve("sent"); });
278280
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
279281
const response = await recorded(input, init);
280-
if (String(input).endsWith("/GetChatMessage") && requests.length === 1) await held;
282+
if (String(input).endsWith("/GetChatMessage") && requests.length === 1) {
283+
sent();
284+
await held;
285+
}
281286
return response;
282287
}) as typeof fetch;
283288
const first = run("swe-2-high", {}, {}, undefined, conversation("conversation-c"));
284-
while (requests.length < 1) await Bun.sleep(1);
285-
await run("swe-2-high", {}, {}, undefined, conversation("conversation-c"));
286-
release();
289+
try {
290+
// A first turn that ends without sending would otherwise leave this test waiting.
291+
const ended = first.then(() => "ended" as const, () => "ended" as const);
292+
expect(await Promise.race([firstSent, ended])).toBe("sent");
293+
await run("swe-2-high", {}, {}, undefined, conversation("conversation-c"));
294+
} finally {
295+
release();
296+
}
287297
await first;
288298
await run("swe-2-high", {}, {}, undefined, conversation("conversation-c"));
289299
const [live, overlapping, later] = sentTrajectories();
@@ -292,6 +302,26 @@ describe("one catalog read serves the cached chat path", () => {
292302
expect(later).toBe(live);
293303
});
294304

305+
test("a failed turn still releases its conversation's trajectory", async () => {
306+
seed([{ uid: "swe-2-high", window: 262_000 }]);
307+
const recorded = globalThis.fetch;
308+
let failed = false;
309+
globalThis.fetch = (async (input: RequestInfo | URL, init?: RequestInit) => {
310+
const response = await recorded(input, init);
311+
if (!failed && String(input).endsWith("/GetChatMessage")) {
312+
failed = true;
313+
return new Response("rejected", { status: 400 });
314+
}
315+
return response;
316+
}) as typeof fetch;
317+
const failedTurn = await run("swe-2-high", {}, {}, undefined, conversation("conversation-d"));
318+
expect(failedTurn.some(event => event.type === "error")).toBe(true);
319+
const nextTurn = await run("swe-2-high", {}, {}, undefined, conversation("conversation-d"));
320+
expect(nextTurn.some(event => event.type === "error")).toBe(false);
321+
const trajectories = sentTrajectories();
322+
expect(trajectories.at(-1)).toBe(trajectories[0]);
323+
});
324+
295325
test("an already cancelled turn never fetches metadata or sends inference", async () => {
296326
const controller = new AbortController();
297327
controller.abort();

0 commit comments

Comments
 (0)