Skip to content

Commit 602362f

Browse files
committed
Add strict: true for fireworks tool calls
1 parent 200cbdf commit 602362f

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

web/src/llm-api/fireworks.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff 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 }

0 commit comments

Comments
 (0)