@@ -31,9 +31,6 @@ export type OpenAiNativeModel = ReturnType<OpenAiNativeHandler["getModel"]>
3131// Constants for model identification
3232const GPT5_MODEL_PREFIX = "gpt-5"
3333
34- // Debug flag for logging (can be controlled via environment variable or config)
35- const DEBUG_RESPONSES_API = process . env . DEBUG_RESPONSES_API === "true"
36-
3734export class OpenAiNativeHandler extends BaseProvider implements SingleCompletionHandler {
3835 protected options : ApiHandlerOptions
3936 private client : OpenAI
@@ -198,7 +195,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
198195 // so requests do not default to very large limits (e.g., 120k).
199196 interface Gpt5RequestBody {
200197 model : string
201- input : string
198+ input : Array < { role : "user" | "assistant" ; content : any [ ] } >
202199 stream : boolean
203200 reasoning ?: { effort : ReasoningEffortWithMinimal ; summary ?: "auto" }
204201 text ?: { verbosity : VerbosityLevel }
@@ -209,7 +206,7 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
209206 instructions ?: string
210207 }
211208
212- return {
209+ const body : Gpt5RequestBody = {
213210 model : model . id ,
214211 input : formattedInput ,
215212 stream : true ,
@@ -224,7 +221,6 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
224221 ...( this . options . enableGpt5ReasoningSummary ? { summary : "auto" as const } : { } ) ,
225222 } ,
226223 } ) ,
227- text : { verbosity : ( verbosity || "medium" ) as VerbosityLevel } ,
228224 // Only include temperature if the model supports it
229225 ...( model . info . supportsTemperature !== false && {
230226 temperature :
@@ -238,6 +234,13 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
238234 ...( model . maxTokens ? { max_output_tokens : model . maxTokens } : { } ) ,
239235 ...( requestPreviousResponseId && { previous_response_id : requestPreviousResponseId } ) ,
240236 }
237+
238+ // Include text.verbosity only when the model explicitly supports it
239+ if ( model . info . supportsVerbosity === true ) {
240+ body . text = { verbosity : ( verbosity || "medium" ) as VerbosityLevel }
241+ }
242+
243+ return body
241244 }
242245
243246 private async * executeRequest (
@@ -269,11 +272,6 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
269272
270273 if ( is400Error && requestBody . previous_response_id && isPreviousResponseError ) {
271274 // Log the error and retry without the previous_response_id
272- if ( DEBUG_RESPONSES_API ) {
273- console . debug (
274- `[Responses API] Previous response ID not found (${ requestBody . previous_response_id } ), retrying without it` ,
275- )
276- }
277275
278276 // Remove the problematic previous_response_id and retry
279277 const retryRequestBody = { ...requestBody }
@@ -440,11 +438,6 @@ export class OpenAiNativeHandler extends BaseProvider implements SingleCompletio
440438
441439 if ( response . status === 400 && requestBody . previous_response_id && isPreviousResponseError ) {
442440 // Log the error and retry without the previous_response_id
443- if ( DEBUG_RESPONSES_API ) {
444- console . debug (
445- `[Responses API] Previous response ID not found (${ requestBody . previous_response_id } ), retrying without it` ,
446- )
447- }
448441
449442 // Remove the problematic previous_response_id and retry
450443 const retryRequestBody = { ...requestBody }
0 commit comments