File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed
Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -106,6 +106,19 @@ function createFireworksRequest(params: {
106106 delete fireworksBody . codebuff_metadata
107107 delete fireworksBody . usage
108108
109+ // Add strict: true to tool definitions to prevent hallucinated tool call formats
110+ if ( Array . isArray ( fireworksBody . tools ) ) {
111+ fireworksBody . tools = ( fireworksBody . tools as Array < Record < string , unknown > > ) . map ( ( tool ) => {
112+ if ( tool . type === 'function' && typeof tool . function === 'object' && tool . function !== null ) {
113+ return {
114+ ...tool ,
115+ function : { ...( tool . function as Record < string , unknown > ) , strict : true } ,
116+ }
117+ }
118+ return tool
119+ } )
120+ }
121+
109122 // For streaming, request usage in the final chunk
110123 if ( fireworksBody . stream ) {
111124 fireworksBody . stream_options = { include_usage : true }
You can’t perform that action at this time.
0 commit comments