Skip to content

Commit 2ff83bc

Browse files
committed
fix(providers): answer every Sakana tool_call to keep message history valid
An assistant message lists all tool_calls, so a call for an unconfigured tool must still get a matching `tool` response or the next request violates the OpenAI message contract. Emit an error tool-result for unknown tools instead of dropping them.
1 parent 3a24274 commit 2ff83bc

1 file changed

Lines changed: 19 additions & 1 deletion

File tree

apps/sim/providers/sakana/index.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,25 @@ export const sakanaProvider: ProviderConfig = {
257257
const toolArgs = JSON.parse(toolCall.function.arguments)
258258
const tool = request.tools?.find((t) => t.id === toolName)
259259

260-
if (!tool) return null
260+
// Every tool_call in the assistant message must be answered by a matching
261+
// `tool` message, or the next request violates the OpenAI message contract.
262+
// Emit an error result for an unknown tool rather than dropping it.
263+
if (!tool) {
264+
const toolCallEndTime = Date.now()
265+
return {
266+
toolCall,
267+
toolName,
268+
toolParams: {},
269+
result: {
270+
success: false,
271+
output: undefined,
272+
error: `Tool "${toolName}" is not available`,
273+
},
274+
startTime: toolCallStartTime,
275+
endTime: toolCallEndTime,
276+
duration: toolCallEndTime - toolCallStartTime,
277+
}
278+
}
261279

262280
const { toolParams, executionParams } = prepareToolExecution(tool, toolArgs, request)
263281
const result = await executeTool(toolName, executionParams, {

0 commit comments

Comments
 (0)