Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions integration-tests/sdk-typescript/abort-and-lifecycle.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -496,6 +506,7 @@ describe('AbortController and Process Lifecycle (E2E)', () => {
},
});

let hasTextContent = false;
try {
for await (const message of q) {
if (isSDKAssistantMessage(message)) {
Expand All @@ -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);
}
});
Expand Down
8 changes: 6 additions & 2 deletions integration-tests/sdk-typescript/multi-turn.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/);
Expand Down