@@ -2,41 +2,51 @@ import { describe, expect, test } from "bun:test"
22import { resolveChunkTimeout , SSEStallError , wrapSSE } from "../../src/provider/provider"
33
44describe ( "provider.resolveChunkTimeout" , ( ) => {
5- test ( "returns 120s default when undefined for generic provider " , ( ) => {
6- expect ( resolveChunkTimeout ( "github-copilot" , undefined ) ) . toBe ( 120_000 )
5+ test ( "returns 120s default when undefined and reasoning=false " , ( ) => {
6+ expect ( resolveChunkTimeout ( { providerID : "github-copilot" , reasoning : false } , undefined ) ) . toBe ( 120_000 )
77 } )
88
9- test ( "returns 600s default for Anthropic " , ( ) => {
10- expect ( resolveChunkTimeout ( "anthropic" , undefined ) ) . toBe ( 600_000 )
9+ test ( "returns 600s default when reasoning=true on anthropic " , ( ) => {
10+ expect ( resolveChunkTimeout ( { providerID : "anthropic" , reasoning : true } , undefined ) ) . toBe ( 600_000 )
1111 } )
1212
13- test ( "returns 600s default for google-vertex- anthropic" , ( ) => {
14- expect ( resolveChunkTimeout ( "google-vertex-anthropic" , undefined ) ) . toBe ( 600_000 )
13+ test ( "returns 600s default for reasoning=true regardless of provider ID (openrouter → anthropic/*) " , ( ) => {
14+ expect ( resolveChunkTimeout ( { providerID : "openrouter" , reasoning : true } , undefined ) ) . toBe ( 600_000 )
1515 } )
1616
17- test ( "returns 600s default for amazon-bedrock" , ( ) => {
18- expect ( resolveChunkTimeout ( "amazon-bedrock" , undefined ) ) . toBe ( 600_000 )
17+ test ( "returns 600s default when reasoning=true on google-vertex-anthropic" , ( ) => {
18+ expect ( resolveChunkTimeout ( { providerID : "google-vertex-anthropic" , reasoning : true } , undefined ) ) . toBe ( 600_000 )
19+ } )
20+
21+ test ( "returns 600s default when reasoning=true on amazon-bedrock" , ( ) => {
22+ expect ( resolveChunkTimeout ( { providerID : "amazon-bedrock" , reasoning : true } , undefined ) ) . toBe ( 600_000 )
23+ } )
24+
25+ test ( "returns 120s default when reasoning=false on anthropic (non-reasoning Claude)" , ( ) => {
26+ expect ( resolveChunkTimeout ( { providerID : "anthropic" , reasoning : false } , undefined ) ) . toBe ( 120_000 )
1927 } )
2028
2129 test ( "returns 0 when explicitly disabled with false" , ( ) => {
22- expect ( resolveChunkTimeout ( "github-copilot" , false ) ) . toBe ( 0 )
30+ expect ( resolveChunkTimeout ( { providerID : "github-copilot" , reasoning : false } , false ) ) . toBe ( 0 )
2331 } )
2432
2533 test ( "returns the user value when a positive number" , ( ) => {
26- expect ( resolveChunkTimeout ( "github-copilot" , 60_000 ) ) . toBe ( 60_000 )
34+ expect ( resolveChunkTimeout ( { providerID : "github-copilot" , reasoning : false } , 60_000 ) ) . toBe ( 60_000 )
2735 } )
2836
2937 test ( "explicit positive number wins over extended-thinking default" , ( ) => {
30- expect ( resolveChunkTimeout ( "anthropic" , 30_000 ) ) . toBe ( 30_000 )
38+ expect ( resolveChunkTimeout ( { providerID : "anthropic" , reasoning : true } , 30_000 ) ) . toBe ( 30_000 )
3139 } )
3240
3341 test ( "false wins over extended-thinking default (returns 0)" , ( ) => {
34- expect ( resolveChunkTimeout ( "anthropic" , false ) ) . toBe ( 0 )
42+ expect ( resolveChunkTimeout ( { providerID : "anthropic" , reasoning : true } , false ) ) . toBe ( 0 )
3543 } )
3644
37- test ( "falls back to provider default for non-numeric junk" , ( ) => {
45+ test ( "falls back to model default for non-numeric junk" , ( ) => {
3846 // Defensive branch — config schema prevents this, but runtime check guards misconfig.
39- expect ( resolveChunkTimeout ( "github-copilot" , "not-a-number" as never ) ) . toBe ( 120_000 )
47+ expect ( resolveChunkTimeout ( { providerID : "github-copilot" , reasoning : false } , "not-a-number" as never ) ) . toBe (
48+ 120_000 ,
49+ )
4050 } )
4151} )
4252
0 commit comments