John O'Reilly
06/28/2025, 9:06 AMJohn O'Reilly
06/28/2025, 9:07 AM@LLMDescription("Tools for getting climate emission information")
class MyFirstToolSet : ToolSet {
@Tool
@LLMDescription("Get the emission data for a country.")
fun getEmissions(
@LLMDescription("The country")
country: String,
@LLMDescription("The year")
year: String
): String {
return "300"
}
}
John O'Reilly
06/28/2025, 9:08 AMGet emisssions for France, Germany and Spain for 2023 and 2024.
John O'Reilly
06/28/2025, 9:16 AMtoolRegistry
value used when constructing AIAgent
is set to ToolRegistry { MyFirstToolSet() }
Didier Villevalois
06/28/2025, 9:39 AMToolRegistry
builder? Something like: ToolRegistry { tools(MyFirstToolSet()) }
John O'Reilly
06/28/2025, 9:52 AMDidier Villevalois
06/28/2025, 9:55 AM.asTools()
that was missing but has been added recently in the repo... What version are you using? 0.2.1 or the develop branch?John O'Reilly
06/28/2025, 9:56 AMJohn O'Reilly
06/28/2025, 10:00 AMval myFirstToolSetRegistry = ToolRegistry {
tools(MyFirstToolSet().asTools())
}
Didier Villevalois
06/28/2025, 10:02 AMToolRegistry.Builder.tools(toolSet: ToolSet)
was missing and has been added recently (https://github.com/JetBrains/koog/commit/710f9eaac0106e2101e52807a0b6386559454adb). You have to do .asTools()
by yourself in the 0.2.1.
The doc is not fully in sync, but that will change as it is being moved inside the repository...John O'Reilly
06/28/2025, 10:50 AM[main] ERROR ai.koog.agents.core.agent.AIAgent - Tool "getEmissions" failed to parse arguments: {"country":"France","year":2022}
kotlinx.serialization.json.internal.JsonDecodingException: String literal for key 'year' should be quoted at element: $.year.
Use 'isLenient = true' in 'Json {}' builder to accept non-compliant JSON.
John O'Reilly
06/28/2025, 10:51 AM@Tool(customName = "getEmissions")
@LLMDescription("Get the emission data for a country.")
fun getEmissions(
@LLMDescription("The country")
country: String,
@LLMDescription("The year")
year: String
): String
Didier Villevalois
06/28/2025, 10:55 AMJohn O'Reilly
06/28/2025, 12:12 PM