Pedro Ribeiro
10/08/2025, 1:04 PMjava.lang.IllegalStateException: Error from OpenAILLMClient API: 400 Bad Request: {
"error": {
"message": "An assistant message with 'tool_calls' must be followed by tool messages responding to each 'tool_call_id'. The following tool_call_ids did not have response messages: call_AiXXX",
"type": "invalid_request_error",
"param": "messages.[5].role",
"code": null
}
}
Here is a snippet of the code:
edge(nodeStart forwardTo nodeCallLLM)
edge((nodeCallLLM forwardTo askUserPermissionForToolCall) onToolCall { true })
edge((askUserPermissionForToolCall forwardTo nodeExecuteTool) onToolCallApproved { true })
edge((askUserPermissionForToolCall forwardTo nodeCallLLM) onToolCallRejected { true })
@EdgeTransformationDslMarker
infix fun <IncomingOutput, IntermediateOutput, OutgoingInput> AIAgentEdgeBuilderIntermediate<IncomingOutput, IntermediateOutput, OutgoingInput>.onToolCallRejected(
block: suspend (ToolExecutionConsent.Rejected) -> Boolean
): AIAgentEdgeBuilderIntermediate<IncomingOutput, String, OutgoingInput> {
return onIsInstance(ToolExecutionConsent.Rejected::class)
.onCondition { signature -> block(signature) }
.transformed { it.feedback }
}
My intuition is that I need to return a ReceivedToolResult with the rejection message (instead of just the feedback) and forward it to nodeLLMSendToolResult() instead of nodeLLMRequest(). Wondering if anyone tried to implement something similar and how to make it work.Didier Villevalois
10/08/2025, 4:26 PMDidier Villevalois
10/08/2025, 4:27 PMnodeExecuteVettedToolCalls is handling parallel tool calls too.Pedro Ribeiro
10/08/2025, 4:42 PMAntonii Belyshev
10/08/2025, 7:12 PM@Tool
fun myTool(args: Args): Result {
if (!askForApproval()) error("User did not approve the tool call")
// you tool code
}
Then koog will handle the error and generate the tool result with the error message as the result.Vadim Briliantov
10/08/2025, 9:47 PMPedro Ribeiro
10/09/2025, 10:03 AMReadFileTool without overriding them.