File tree Expand file tree Collapse file tree 1 file changed +8
-8
lines changed
agents/agents-core/src/commonMain/kotlin/ai/koog/agents/core/agent/session Expand file tree Collapse file tree 1 file changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -117,14 +117,14 @@ public sealed class AIAgentLLMSession(
117117
118118 public open suspend fun requestLLMWithoutTools (): Message .Response {
119119 validateSession()
120- val promptWithDisabledTools = prompt.withUpdatedParams {
121- /*
122- If tools are empty, they will not be added by the LLM client to the requests,
123- which means tool choice parameter cannot be used (it throws an exception without a tools parameter present).
124- So instead set it to null in this case, which behaves the same (there are no tools to call, after all).
125- */
126- toolChoice = if (tools.isNotEmpty( )) LLMParams . ToolChoice . None else null
127- }
120+ /*
121+ Not all LLM providers support tool list when tool choice is set to "none", so we are rewriting all tool messages to regular messages,
122+ for all requests without tools.
123+ */
124+ val promptWithDisabledTools = prompt
125+ .withUpdatedParams { toolChoice = null }
126+ . let { preparePrompt(it, emptyList( )) }
127+
128128 return executeSingle(promptWithDisabledTools, tools)
129129 }
130130
You can’t perform that action at this time.
0 commit comments