@@ -41,6 +41,13 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
41
41
private responseIdPromise : Promise < string | undefined > | undefined
42
42
private responseIdResolver : ( ( value : string | undefined ) => void ) | undefined
43
43
44
+ // Internal debug logger for conditional diagnostics
45
+ private logDebug ( ...args : any [ ] ) : void {
46
+ if ( DEBUG_RESPONSES_API ) {
47
+ console . debug ( ...args )
48
+ }
49
+ }
50
+
44
51
// Event types handled by the shared event processor to avoid duplication
45
52
private readonly coreHandledEventTypes = new Set < string > ( [
46
53
"response.text.delta" ,
@@ -268,11 +275,9 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
268
275
269
276
if ( is400Error && requestBody . previous_response_id && isPreviousResponseError ) {
270
277
// Log the error and retry without the previous_response_id
271
- if ( DEBUG_RESPONSES_API ) {
272
- console . debug (
273
- `[Responses API] Previous response ID not found (${ requestBody . previous_response_id } ), retrying without it` ,
274
- )
275
- }
278
+ this . logDebug (
279
+ `[Responses API] Previous response ID not found (${ requestBody . previous_response_id } ), retrying without it` ,
280
+ )
276
281
277
282
// Remove the problematic previous_response_id and retry
278
283
const retryRequestBody = { ...requestBody }
@@ -442,11 +447,9 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
442
447
443
448
if ( response . status === 400 && requestBody . previous_response_id && isPreviousResponseError ) {
444
449
// Log the error and retry without the previous_response_id
445
- if ( DEBUG_RESPONSES_API ) {
446
- console . debug (
447
- `[Responses API] Previous response ID not found (${ requestBody . previous_response_id } ), retrying without it` ,
448
- )
449
- }
450
+ this . logDebug (
451
+ `[Responses API] Previous response ID not found (${ requestBody . previous_response_id } ), retrying without it` ,
452
+ )
450
453
451
454
// Remove the problematic previous_response_id and retry
452
455
const retryRequestBody = { ...requestBody }
0 commit comments