From 50a0245c88e6d0b4a829d9d0924417f6a54a7063 Mon Sep 17 00:00:00 2001 From: Shaojin Wen Date: Wed, 20 May 2026 09:27:26 +0800 Subject: [PATCH] fix(test): count result messages instead of assistant messages in multi-model E2E test Each turn produces multiple assistant messages (thinking + text), but the test was counting each one as a separate turn. This caused the third setModel to fire before the third turn actually started, so only 2 system messages were captured instead of the expected 3. Resolve turn-completion promises on isSDKResultMessage (one per turn) instead of isSDKAssistantMessage. --- .../sdk-typescript/system-control.test.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/integration-tests/sdk-typescript/system-control.test.ts b/integration-tests/sdk-typescript/system-control.test.ts index f7144331f5b..212dad8390c 100644 --- a/integration-tests/sdk-typescript/system-control.test.ts +++ b/integration-tests/sdk-typescript/system-control.test.ts @@ -250,7 +250,7 @@ describe('System Control (E2E)', () => { try { const systemMessages: Array<{ model?: string }> = []; - let responseCount = 0; + let turnCount = 0; const resolvers: Array<() => void> = []; const responsePromises = [ new Promise((resolve) => resolvers.push(resolve)), @@ -265,11 +265,11 @@ describe('System Control (E2E)', () => { } if (isSDKResultMessage(message)) { resultWaiter.notifyResult(); - } - if (isSDKAssistantMessage(message)) { - if (responseCount < resolvers.length) { - resolvers[responseCount]?.(); - responseCount++; + // Resolve on result (one per turn), not assistant message + // (which may fire multiple times per turn: thinking + text) + if (turnCount < resolvers.length) { + resolvers[turnCount]?.(); + turnCount++; } } }