When using code like following (for a single-run a...
# koog-agentic-framework
j
When using code like following (for a single-run agent) is there way to get the tool invocations to happen parallel....thought I saw some mention of that somewhere but can't find it now.
Copy code
strategy = functionalStrategy { input ->
    var responses = requestLLMMultiple(input)

    while (responses.containsToolCalls()) {
        val pendingCalls = extractToolCalls(responses)
        val results = executeMultipleTools(pendingCalls)
        responses = sendMultipleToolResults(results)
    }

    responses.single().asAssistantMessage().content
},
For example I have "Get per capita emission data for Spain, France, Germany, and Italy for the year 2024." prompt which triggers following tool invocations. The
GetCountryTool
calls could be run in parallel and likewise
GetPopulationTool
ones.
Copy code
[GetCountryTool {"countryName":"Spain"}]
[GetCountryTool {"countryName":"France"}]
[GetCountryTool {"countryName":"Germany"}]
[GetCountryTool {"countryName":"Italy"}]
[GetPopulationTool {"countryCode":"ESP"}]
[GetPopulationTool {"countryCode":"FRA"}]
[GetPopulationTool {"countryCode":"DEU"}]
[GetPopulationTool {"countryCode":"ITA"}]
[GetEmissionsTool {"countryCodeList":["ESP","FRA","DEU","ITA"],"year":"2024"}]
d
IIRC, the second parameter of
executeMultipleCalls
is a Boolean named
parallelToolCalls
(or something like it).
j
ah, I missed that, thanks....the issue then is that that list has always just one entry....
pendingCalls
always returns just 1 tool
d
That may depend on the model you use...
j
Ah, looks like that was it.....had been testing that time with Ollama (with gpt-oss:20b model).....switched to Gemini and see for example
pendingCalls
containing list of those first 4 tool calls
🔥 2
much faster!
now see
Copy code
Pending Calls
[GetCountryTool {"countryName":"Spain"}, GetCountryTool {"countryName":"France"}, GetCountryTool {"countryName":"Germany"}, GetCountryTool {"countryName":"Italy"}]
Pending Calls
[GetPopulationTool {"countryCode":"ESP"}, GetPopulationTool {"countryCode":"FRA"}, GetPopulationTool {"countryCode":"DEU"}, GetPopulationTool {"countryCode":"ITA"}, GetEmissionsTool {"year":"2024","countryCodeList":["ESP","FRA","DEU","ITA"]}]
d
@John O'Reilly shouldn't you make a single tool, like for instance getPopulationsAndEmissions in order to avoid useless LLM calls? It would take a list of country names, directly and would return a list of triplets (country code, population, emissions). Or maybe I am missing something.
j
Yeah, I guess I could probably do something like that.....I had started off with just emission data (obtained from particular endpoint) and then later added tool to get population data (from different endpoint) to allow per-capita info......had also sort of wanted to show how different tools could be combined like this as well
d
Yeah, that would not show off tool call orchestration... 😆
j