From f14a29d297e34407436ea6da87b9173b2889b660 Mon Sep 17 00:00:00 2001 From: HiranoMasaaki Date: Sun, 15 Feb 2026 11:39:10 +0000 Subject: [PATCH 1/2] fix: Prevent undefined result in reasoning budget assertions `x.thinking && x.thinking.length > 0` returns `undefined` (not `false`) when `thinking` is undefined, causing `expect(undefined).toBe(true)` to fail. Use optional chaining with nullish coalescing instead. Co-Authored-By: Claude Opus 4.6 --- e2e/perstack-cli/reasoning-budget.test.ts | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/e2e/perstack-cli/reasoning-budget.test.ts b/e2e/perstack-cli/reasoning-budget.test.ts index a281ea60..fb814af0 100644 --- a/e2e/perstack-cli/reasoning-budget.test.ts +++ b/e2e/perstack-cli/reasoning-budget.test.ts @@ -110,7 +110,7 @@ describe("Reasoning Budget", () => { // Note: AI SDK currently doesn't report reasoningTokens for Anthropic, // but we can verify thinking content is generated const hasThinking = - result.reasoningTokens > 0 || (result.thinking && result.thinking.length > 0) + result.reasoningTokens > 0 || ((result.thinking?.length ?? 0) > 0) expect(hasThinking).toBe(true) }, LLM_TIMEOUT, @@ -167,9 +167,9 @@ describe("Reasoning Budget", () => { // Note: AI SDK currently doesn't report reasoningTokens for Anthropic const minimalHasThinking = minimalResult.reasoningTokens > 0 || - (minimalResult.thinking && minimalResult.thinking.length > 0) + ((minimalResult.thinking?.length ?? 0) > 0) const highHasThinking = - highResult.reasoningTokens > 0 || (highResult.thinking && highResult.thinking.length > 0) + highResult.reasoningTokens > 0 || ((highResult.thinking?.length ?? 0) > 0) expect(minimalHasThinking).toBe(true) expect(highHasThinking).toBe(true) }, @@ -203,7 +203,7 @@ describe("Reasoning Budget", () => { // OpenAI reasoning models may not always surface reasoning token counts, // so verify either tokens or thinking text is present const hasReasoning = - result.reasoningTokens > 0 || (result.thinking && result.thinking.length > 0) + result.reasoningTokens > 0 || ((result.thinking?.length ?? 0) > 0) expect(hasReasoning).toBe(true) }, LLM_TIMEOUT, @@ -221,7 +221,7 @@ describe("Reasoning Budget", () => { // At least one budget level should produce reasoning tokens or thinking text const highHasReasoning = - highResult.reasoningTokens > 0 || (highResult.thinking && highResult.thinking.length > 0) + highResult.reasoningTokens > 0 || ((highResult.thinking?.length ?? 0) > 0) expect(highHasReasoning).toBe(true) }, LLM_TIMEOUT * 2, // Two API calls @@ -253,7 +253,7 @@ describe("Reasoning Budget", () => { expect(result.success).toBe(true) // Flash thinking should produce reasoning tokens or thinking text const hasThinking = - result.reasoningTokens > 0 || (result.thinking && result.thinking.length > 0) + result.reasoningTokens > 0 || ((result.thinking?.length ?? 0) > 0) expect(hasThinking).toBe(true) }, LLM_TIMEOUT, @@ -272,9 +272,9 @@ describe("Reasoning Budget", () => { // Both should produce reasoning tokens or thinking text const minimalHasThinking = minimalResult.reasoningTokens > 0 || - (minimalResult.thinking && minimalResult.thinking.length > 0) + ((minimalResult.thinking?.length ?? 0) > 0) const highHasThinking = - highResult.reasoningTokens > 0 || (highResult.thinking && highResult.thinking.length > 0) + highResult.reasoningTokens > 0 || ((highResult.thinking?.length ?? 0) > 0) expect(minimalHasThinking).toBe(true) expect(highHasThinking).toBe(true) }, From 9591fec9124440cdce87177591cd5185bb767327 Mon Sep 17 00:00:00 2001 From: HiranoMasaaki Date: Sun, 15 Feb 2026 11:47:29 +0000 Subject: [PATCH 2/2] style: Fix formatting in reasoning-budget test Co-Authored-By: Claude Opus 4.6 --- e2e/perstack-cli/reasoning-budget.test.ts | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/e2e/perstack-cli/reasoning-budget.test.ts b/e2e/perstack-cli/reasoning-budget.test.ts index fb814af0..0a92dc91 100644 --- a/e2e/perstack-cli/reasoning-budget.test.ts +++ b/e2e/perstack-cli/reasoning-budget.test.ts @@ -109,8 +109,7 @@ describe("Reasoning Budget", () => { // Extended thinking should produce reasoning tokens or thinking text // Note: AI SDK currently doesn't report reasoningTokens for Anthropic, // but we can verify thinking content is generated - const hasThinking = - result.reasoningTokens > 0 || ((result.thinking?.length ?? 0) > 0) + const hasThinking = result.reasoningTokens > 0 || (result.thinking?.length ?? 0) > 0 expect(hasThinking).toBe(true) }, LLM_TIMEOUT, @@ -166,10 +165,9 @@ describe("Reasoning Budget", () => { // Both should produce reasoning tokens or thinking text // Note: AI SDK currently doesn't report reasoningTokens for Anthropic const minimalHasThinking = - minimalResult.reasoningTokens > 0 || - ((minimalResult.thinking?.length ?? 0) > 0) + minimalResult.reasoningTokens > 0 || (minimalResult.thinking?.length ?? 0) > 0 const highHasThinking = - highResult.reasoningTokens > 0 || ((highResult.thinking?.length ?? 0) > 0) + highResult.reasoningTokens > 0 || (highResult.thinking?.length ?? 0) > 0 expect(minimalHasThinking).toBe(true) expect(highHasThinking).toBe(true) }, @@ -202,8 +200,7 @@ describe("Reasoning Budget", () => { expect(result.success).toBe(true) // OpenAI reasoning models may not always surface reasoning token counts, // so verify either tokens or thinking text is present - const hasReasoning = - result.reasoningTokens > 0 || ((result.thinking?.length ?? 0) > 0) + const hasReasoning = result.reasoningTokens > 0 || (result.thinking?.length ?? 0) > 0 expect(hasReasoning).toBe(true) }, LLM_TIMEOUT, @@ -221,7 +218,7 @@ describe("Reasoning Budget", () => { // At least one budget level should produce reasoning tokens or thinking text const highHasReasoning = - highResult.reasoningTokens > 0 || ((highResult.thinking?.length ?? 0) > 0) + highResult.reasoningTokens > 0 || (highResult.thinking?.length ?? 0) > 0 expect(highHasReasoning).toBe(true) }, LLM_TIMEOUT * 2, // Two API calls @@ -252,8 +249,7 @@ describe("Reasoning Budget", () => { expect(result.success).toBe(true) // Flash thinking should produce reasoning tokens or thinking text - const hasThinking = - result.reasoningTokens > 0 || ((result.thinking?.length ?? 0) > 0) + const hasThinking = result.reasoningTokens > 0 || (result.thinking?.length ?? 0) > 0 expect(hasThinking).toBe(true) }, LLM_TIMEOUT, @@ -271,10 +267,9 @@ describe("Reasoning Budget", () => { // Both should produce reasoning tokens or thinking text const minimalHasThinking = - minimalResult.reasoningTokens > 0 || - ((minimalResult.thinking?.length ?? 0) > 0) + minimalResult.reasoningTokens > 0 || (minimalResult.thinking?.length ?? 0) > 0 const highHasThinking = - highResult.reasoningTokens > 0 || ((highResult.thinking?.length ?? 0) > 0) + highResult.reasoningTokens > 0 || (highResult.thinking?.length ?? 0) > 0 expect(minimalHasThinking).toBe(true) expect(highHasThinking).toBe(true) },