From c35de7ec9ab1eac166fc1a74bb9da3be61975ee8 Mon Sep 17 00:00:00 2001 From: Tam Nhu Tran Date: Thu, 12 Feb 2026 11:04:37 +0700 Subject: [PATCH] test(cliproxy): add thinking suffix test and document exit 0 behavior - Add test case for comma-separated thinking params (32768,extended) - Add clarifying comment to isProviderError() about exit 0 handling --- src/cliproxy/executor/retry-handler.ts | 2 ++ tests/unit/cliproxy/composite-fallback.test.ts | 14 ++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/cliproxy/executor/retry-handler.ts b/src/cliproxy/executor/retry-handler.ts index dd850450..514af33f 100644 --- a/src/cliproxy/executor/retry-handler.ts +++ b/src/cliproxy/executor/retry-handler.ts @@ -125,6 +125,8 @@ export function detectFailedTier( /** Check if Claude exit indicates provider error (vs normal user exit) */ export function isProviderError(exitCode: number, stderr: string): boolean { + // Exit code 0 means success, even if stderr has error-like output + // (could be warnings, debug info, etc.) if (exitCode === 0) return false; return PROVIDER_ERROR_PATTERNS.some((p) => p.test(stderr)); } diff --git a/tests/unit/cliproxy/composite-fallback.test.ts b/tests/unit/cliproxy/composite-fallback.test.ts index 919919eb..338f6a02 100644 --- a/tests/unit/cliproxy/composite-fallback.test.ts +++ b/tests/unit/cliproxy/composite-fallback.test.ts @@ -147,6 +147,20 @@ describe('detectFailedTier', () => { // Should still match because model name is substring expect(result).toBe('opus'); }); + + it('should strip complex thinking suffix with comma-separated params', () => { + const tiersWithComplexBudget: typeof tiers = { + opus: { provider: 'agy', model: 'claude-opus-4-6-thinking(32768,extended)' }, + sonnet: { provider: 'agy', model: 'claude-sonnet-4-5-thinking(high)' }, + haiku: { provider: 'agy', model: 'claude-3-5-haiku' }, + }; + + // Stderr contains base model name without suffix + const stderr = 'Error: claude-opus-4-6-thinking overloaded'; + const result = detectFailedTier(stderr, tiersWithComplexBudget); + // Should match because regex strips (32768,extended) to get base name + expect(result).toBe('opus'); + }); }); // ========================================