From c5e9bc85d4336054a4560ed08e83cf6b08c6e28d Mon Sep 17 00:00:00 2001 From: JUN Date: Thu, 17 Sep 2026 13:28:08 +0900 Subject: [PATCH] test(responses): assert the stream completed, not that it lacks the digits "502" Windows shard 4/9 of run 35180376537 went red on a turn that had succeeded perfectly. The relay stamps every chunk with a random chatcmpl- id, and this run drew chatcmpl-05021785ecf5440c96ca31be. expect(text).not.toContain("502") searched the whole stream, found those three characters inside the id, and failed. tests/images/loop.test.ts already retired the identical assertion for "504" and measured it: roughly one id in 137 contains a given three-digit string, which reddened about one run in 69 for no reason at all. The assertion could not do its job either. This relay's failure mode carries an error frame and ends the turn; the number 502 never appears in the body, so a real failure would have slipped straight past it. It was simultaneously flaky and blind. Assert the terminal shape instead: the stream reached [DONE] and carried no error frame. That detects the failure the case was written for and cannot be moved by a random identifier. No local suite, focused test, typecheck, build, or install was run. --- .../chat-completions-deferred-tools.test.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/responses/chat-completions-deferred-tools.test.ts b/tests/responses/chat-completions-deferred-tools.test.ts index 0bc0fe46e1..b5209e231a 100644 --- a/tests/responses/chat-completions-deferred-tools.test.ts +++ b/tests/responses/chat-completions-deferred-tools.test.ts @@ -179,7 +179,21 @@ describe("chat-completions deferred tool pass-through", () => { const text = await response.text(); expect(text).toContain("todo_write"); expect(text).toContain("call_undeclared_1"); - expect(text).not.toContain("502"); + /* + * Terminal shape, not a substring search for "502". + * + * The old assertion searched the whole stream, and the relay stamps each chunk with a + * random `chatcmpl-` id. Windows shard 4/9 of run 35180376537 drew + * `chatcmpl-05021785ecf5440c96ca31be` and went red on a turn that had succeeded + * perfectly. `tests/images/loop.test.ts` already retired the identical assertion for + * "504" and measured it at roughly one run in 69. + * + * It could not see a real 502 either: this relay's failure carries an error frame and + * ends the turn, and the number never appears in the body. So assert that instead - the + * stream completed and carried no error. + */ + expect(text).toContain("data: [DONE]"); + expect(text).not.toContain("\"error\""); expect(text).not.toContain("undeclared client tool"); } finally { await server.stop(true);