66 openaiModels ,
77} from '@codebuff/common/constants'
88import {
9- endsAgentStepParam ,
109 endToolTag ,
1110 startToolTag ,
1211 toolNameParam ,
@@ -122,21 +121,20 @@ export const promptAiSdkStream = async function* (
122121 } ,
123122 'Error from AI SDK' ,
124123 )
125- if ( process . env . NEXT_PUBLIC_CB_ENVIRONMENT !== 'prod' ) {
126- const errorBody = APICallError . isInstance ( chunk . error )
127- ? chunk . error . responseBody
128- : undefined
129- const mainErrorMessage =
130- chunk . error instanceof Error
131- ? chunk . error . message
132- : typeof chunk . error === 'string'
133- ? chunk . error
134- : JSON . stringify ( chunk . error )
135- const errorMessage = `Error from AI SDK (model ${ options . model } ): ${ buildArray ( [ mainErrorMessage , errorBody ] ) . join ( '\n' ) } `
136- throw new Error ( errorMessage , {
137- cause : chunk . error ,
138- } )
139- }
124+
125+ const errorBody = APICallError . isInstance ( chunk . error )
126+ ? chunk . error . responseBody
127+ : undefined
128+ const mainErrorMessage =
129+ chunk . error instanceof Error
130+ ? chunk . error . message
131+ : typeof chunk . error === 'string'
132+ ? chunk . error
133+ : JSON . stringify ( chunk . error )
134+ const errorMessage = `Error from AI SDK (model ${ options . model } ): ${ buildArray ( [ mainErrorMessage , errorBody ] ) . join ( '\n' ) } `
135+ throw new Error ( errorMessage , {
136+ cause : chunk . error ,
137+ } )
140138 }
141139 if ( chunk . type === 'reasoning' ) {
142140 if ( ! reasoning ) {
@@ -150,9 +148,7 @@ export const promptAiSdkStream = async function* (
150148 if ( chunk . type === 'text-delta' ) {
151149 if ( reasoning ) {
152150 reasoning = false
153- yield `",
154- ${ JSON . stringify ( endsAgentStepParam ) } : false
155- }${ endToolTag } \n\n`
151+ yield `"\n}${ endToolTag } \n\n`
156152 }
157153 content += chunk . textDelta
158154 yield chunk . textDelta
0 commit comments