@@ -3,19 +3,22 @@ import { describe, expect, it } from "vite-plus/test";
33import { providerFailurePresentation } from "./orchestrationV2ThreadError.ts" ;
44
55describe ( "providerFailurePresentation" , ( ) => {
6- it ( "recognizes an OpenCode admission refusal and replaces a legacy title" , ( ) => {
7- expect (
8- providerFailurePresentation (
9- {
10- class : "usage_limit" ,
11- code : "provider.rate-limit" ,
12- message :
13- "Upstream request failed: [ttft_admission_refused] the cell is at capacity; retry shortly (after 30 s)" ,
14- } ,
15- "Usage limit reached" ,
16- ) ,
17- ) . toEqual ( { kind : "provider_capacity" , title : "Provider at capacity" } ) ;
18- } ) ;
6+ it . each ( [ "provider.rate-limit" , "APIError" ] ) (
7+ "recognizes an OpenCode %s admission refusal and replaces a legacy title" ,
8+ ( code ) => {
9+ expect (
10+ providerFailurePresentation (
11+ {
12+ class : "usage_limit" ,
13+ code,
14+ message :
15+ "Upstream request failed: [ttft_admission_refused] the cell is at capacity; retry shortly (after 30 s)" ,
16+ } ,
17+ "Usage limit reached" ,
18+ ) ,
19+ ) . toEqual ( { kind : "provider_capacity" , title : "Provider at capacity" } ) ;
20+ } ,
21+ ) ;
1922
2023 it ( "keeps true quota and ordinary rate-limit failures under the usage-limit title" , ( ) => {
2124 for ( const failure of [
@@ -31,6 +34,12 @@ describe("providerFailurePresentation", () => {
3134 message : "Rate limit exceeded: free-models-per-min." ,
3235 retryable : null ,
3336 } ,
37+ {
38+ class : "usage_limit" ,
39+ code : "APIError" ,
40+ message : "Rate limit exceeded." ,
41+ retryable : null ,
42+ } ,
3443 ] as const ) {
3544 expect ( providerFailurePresentation ( failure ) ) . toEqual ( {
3645 kind : "usage_limit" ,
0 commit comments