@@ -11,7 +11,6 @@ import {
1111 maxConsecutiveCompactionAttempts ,
1212 createCompactionMarkerPart ,
1313 createCompactionTool ,
14- findAPICallError ,
1514 findCompactionSummary ,
1615 isOutOfContextError ,
1716 MAX_CONSECUTIVE_COMPACTION_ATTEMPTS ,
@@ -77,60 +76,6 @@ describe("isOutOfContextError", () => {
7776 true
7877 ) ;
7978 } ) ;
80-
81- test ( "returns true for APICallError in cause chain" , ( ) => {
82- const apiError = createApiError ( "max_tokens_exceeded" ) ;
83- const wrapper = new Error ( "Gateway error" ) ;
84- ( wrapper as { cause ?: unknown } ) . cause = apiError ;
85- expect ( isOutOfContextError ( wrapper ) ) . toBe ( true ) ;
86- } ) ;
87-
88- test ( "returns false for APICallError with unrelated message" , ( ) => {
89- expect ( isOutOfContextError ( createApiError ( "authentication failed" ) ) ) . toBe (
90- false
91- ) ;
92- } ) ;
93-
94- test ( "returns false for non-APICallError even if message matches pattern" , ( ) => {
95- expect ( isOutOfContextError ( new Error ( "context_length_exceeded" ) ) ) . toBe (
96- false
97- ) ;
98- expect ( isOutOfContextError ( "input too long" ) ) . toBe ( false ) ;
99- } ) ;
100- } ) ;
101-
102- describe ( "findAPICallError" , ( ) => {
103- const createApiError = ( message : string ) =>
104- new APICallError ( {
105- message,
106- url : "https://api.example.com" ,
107- requestBodyValues : { } ,
108- statusCode : 400 ,
109- } ) ;
110-
111- test ( "returns the APICallError when provided directly" , ( ) => {
112- const error = createApiError ( "test" ) ;
113- expect ( findAPICallError ( error ) ) . toBe ( error ) ;
114- } ) ;
115-
116- test ( "returns APICallError from single-level cause" , ( ) => {
117- const apiError = createApiError ( "test" ) ;
118- const wrapper = new Error ( "wrapper" ) ;
119- ( wrapper as { cause ?: unknown } ) . cause = apiError ;
120- expect ( findAPICallError ( wrapper ) ) . toBe ( apiError ) ;
121- } ) ;
122-
123- test ( "returns APICallError from deep cause chain" , ( ) => {
124- const apiError = createApiError ( "test" ) ;
125- const wrapper = { cause : { cause : apiError } } ;
126- expect ( findAPICallError ( wrapper ) ) . toBe ( apiError ) ;
127- } ) ;
128-
129- test ( "returns null when no APICallError present" , ( ) => {
130- expect ( findAPICallError ( new Error ( "other" ) ) ) . toBeNull ( ) ;
131- expect ( findAPICallError ( "string" ) ) . toBeNull ( ) ;
132- expect ( findAPICallError ( null ) ) . toBeNull ( ) ;
133- } ) ;
13479} ) ;
13580
13681describe ( "createCompactionTool" , ( ) => {
0 commit comments