diff --git a/integration-tests/sdk-typescript/abort-and-lifecycle.test.ts b/integration-tests/sdk-typescript/abort-and-lifecycle.test.ts index d4566fcf30..6c556d0b38 100644 --- a/integration-tests/sdk-typescript/abort-and-lifecycle.test.ts +++ b/integration-tests/sdk-typescript/abort-and-lifecycle.test.ts @@ -160,6 +160,7 @@ describe('AbortController and Process Lifecycle (E2E)', () => { let completedSuccessfully = false; try { + let hasTextContent = false; for await (const message of q) { if (isSDKAssistantMessage(message)) { const textBlocks = message.message.content.filter( @@ -169,10 +170,15 @@ describe('AbortController and Process Lifecycle (E2E)', () => { .map((b) => b.text) .join('') .slice(0, 100); - expect(text.length).toBeGreaterThan(0); + // Thinking models may emit assistant messages with only thinking + // blocks before the text content arrives, so skip those. + if (text.length > 0) { + hasTextContent = true; + } } } + expect(hasTextContent).toBe(true); completedSuccessfully = true; } catch (error) { // Should not throw for normal completion @@ -239,10 +245,14 @@ describe('AbortController and Process Lifecycle (E2E)', () => { ); const text = textBlocks.map((b: TextBlock) => b.text).join(''); - expect(text.length).toBeGreaterThan(0); + // Thinking models may emit assistant messages with only thinking + // blocks before the text content arrives, so skip those. + if (text.length === 0) { + continue; + } receivedResponse = true; - // End input after receiving first response + // End input after receiving first response with text q.endInput(); endInputCalled = true; } @@ -496,6 +506,7 @@ describe('AbortController and Process Lifecycle (E2E)', () => { }, }); + let hasTextContent = false; try { for await (const message of q) { if (isSDKAssistantMessage(message)) { @@ -506,11 +517,16 @@ describe('AbortController and Process Lifecycle (E2E)', () => { .map((b) => b.text) .join('') .slice(0, 50); - expect(text.length).toBeGreaterThan(0); + // Thinking models may emit assistant messages with only thinking + // blocks before the text content arrives, so skip those. + if (text.length > 0) { + hasTextContent = true; + } } } } finally { await q.close(); + expect(hasTextContent).toBe(true); expect(stderrMessages.length).toBeGreaterThan(0); } }); diff --git a/integration-tests/sdk-typescript/multi-turn.test.ts b/integration-tests/sdk-typescript/multi-turn.test.ts index 4cf845fc5c..d7e723baa5 100644 --- a/integration-tests/sdk-typescript/multi-turn.test.ts +++ b/integration-tests/sdk-typescript/multi-turn.test.ts @@ -147,12 +147,16 @@ describe('Multi-Turn Conversations (E2E)', () => { if (isSDKAssistantMessage(message)) { assistantMessages.push(message); const text = extractText(message.message.content); - assistantTexts.push(text); + // Thinking models may emit assistant messages with only thinking + // blocks before the text content arrives, so skip those. + if (text.length > 0) { + assistantTexts.push(text); + } } } expect(messages.length).toBeGreaterThan(0); - expect(assistantMessages.length).toBeGreaterThanOrEqual(3); + expect(assistantTexts.length).toBeGreaterThanOrEqual(3); // Validate content of responses expect(assistantTexts[0]).toMatch(/2/);