Skip to content

Conversation

tiginamaria
Copy link
Collaborator

@tiginamaria tiginamaria commented Jun 4, 2025

Add parallel nodes execution implementation
#255

Copy link

github-actions bot commented Jun 10, 2025

Qodana for JVM

136 new problems were found

Inspection name Severity Problems
Check Kotlin and Java source code coverage 🔶 Warning 129
Vulnerable imported dependency 🔶 Warning 4
Unused import directive 🔶 Warning 3
@@ Code coverage @@
+ 52% total lines covered
5890 lines analyzed, 3109 lines covered
# Calculated according to the filters of your coverage tool

☁️ View the detailed Qodana report

Detected 116 dependencies

Third-party software list

This page lists the third-party software dependencies used in koog-agents

Dependency Version Licenses
annotations 13.0 Apache-2.0
annotations 23.0.0 Apache-2.0
atomicfu-js 0.26.1 Apache-2.0
config 1.4.3 Apache-2.0
dokka-core 2.0.0 Apache-2.0
dokka-gradle-plugin 2.0.0 Apache-2.0
fus-statistics-gradle-plugin 2.1.21 Apache-2.0
jackson-annotations 2.12.7 Apache-2.0
jackson-core 2.12.7 Apache-2.0
jackson-databind 2.12.7.1 Apache-2.0
jackson-dataformat-xml 2.12.7 Apache-2.0
jackson-module-jaxb-annotations 2.12.7 Apache-2.0
jackson-module-kotlin 2.12.7 Apache-2.0
jakarta.activation-api 1.2.1 BSD-3-Clause
jakarta.xml.bind-api 2.3.2 BSD-3-Clause
jet-sign 45.47 Apache-2.0
kotlin-dom-api-compat 2.1.21 Apache-2.0
kotlin-gradle-plugin-api 2.1.21 Apache-2.0
kotlin-gradle-plugin-model 2.1.21 Apache-2.0
kotlin-gradle-plugin 2.1.21 Apache-2.0
kotlin-logging-js 7.0.7 Apache-2.0
kotlin-logging-jvm 7.0.7 Apache-2.0
kotlin-logging 7.0.7 Apache-2.0
kotlin-reflect 2.0.21 Apache-2.0
kotlin-reflect 2.1.21 Apache-2.0
kotlin-sdk-jvm 0.5.0 MIT
kotlin-stdlib-js 2.1.21 Apache-2.0
kotlin-stdlib 2.0.21 Apache-2.0
kotlin-stdlib 2.1.21 Apache-2.0
kotlinx-coroutines-core-js 1.10.2 Apache-2.0
kotlinx-coroutines-core-jvm 1.10.2 Apache-2.0
kotlinx-coroutines-core-jvm 1.8.0 Apache-2.0
kotlinx-coroutines-core 1.10.2 Apache-2.0
kotlinx-coroutines-reactive 1.10.2 Apache-2.0
kotlinx-coroutines-slf4j 1.10.2 Apache-2.0
kotlinx-datetime-js 0.6.2 Apache-2.0
kotlinx-datetime-jvm 0.6.2 Apache-2.0
kotlinx-datetime 0.6.2 Apache-2.0
kotlinx-io-bytestring-js 0.7.0 Apache-2.0
kotlinx-io-bytestring-jvm 0.7.0 Apache-2.0
kotlinx-io-bytestring 0.7.0 Apache-2.0
kotlinx-io-core-js 0.7.0 Apache-2.0
kotlinx-io-core-jvm 0.7.0 Apache-2.0
kotlinx-io-core 0.7.0 Apache-2.0
kotlinx-serialization-core-js 1.8.1 Apache-2.0
kotlinx-serialization-core-jvm 1.8.1 Apache-2.0
kotlinx-serialization-core 1.8.1 Apache-2.0
kotlinx-serialization-json-io-js 1.7.3 Apache-2.0
kotlinx-serialization-json-io-jvm 1.8.1 Apache-2.0
kotlinx-serialization-json-io 1.7.3 Apache-2.0
kotlinx-serialization-json-js 1.8.1 Apache-2.0
kotlinx-serialization-json-jvm 1.8.1 Apache-2.0
kotlinx-serialization-json 1.8.1 Apache-2.0
ktor-client-cio-jvm 3.0.3 Apache-2.0
ktor-client-content-negotiation-js 3.0.3 Apache-2.0
ktor-client-content-negotiation-jvm 3.0.3 Apache-2.0
ktor-client-content-negotiation 3.0.3 Apache-2.0
ktor-client-core-js 3.0.3 Apache-2.0
ktor-client-core-jvm 3.0.3 Apache-2.0
ktor-client-core 3.0.3 Apache-2.0
ktor-client-js-js 3.0.3 Apache-2.0
ktor-client-logging-js 3.0.3 Apache-2.0
ktor-client-logging-jvm 3.0.3 Apache-2.0
ktor-client-logging 3.0.3 Apache-2.0
ktor-events-js 3.0.3 Apache-2.0
ktor-events-jvm 3.0.3 Apache-2.0
ktor-events 3.0.3 Apache-2.0
ktor-http-cio-js 3.0.3 Apache-2.0
ktor-http-cio-jvm 3.0.3 Apache-2.0
ktor-http-cio 3.0.3 Apache-2.0
ktor-http-js 3.0.3 Apache-2.0
ktor-http-jvm 3.0.3 Apache-2.0
ktor-http 3.0.3 Apache-2.0
ktor-io-js 3.0.3 Apache-2.0
ktor-io-jvm 3.0.3 Apache-2.0
ktor-io 3.0.3 Apache-2.0
ktor-network-jvm 3.0.3 Apache-2.0
ktor-network-tls-jvm 3.0.3 Apache-2.0
ktor-serialization-js 3.0.3 Apache-2.0
ktor-serialization-jvm 3.0.3 Apache-2.0
ktor-serialization-kotlinx-js 3.0.3 Apache-2.0
ktor-serialization-kotlinx-json-js 3.0.3 Apache-2.0
ktor-serialization-kotlinx-json-jvm 3.0.3 Apache-2.0
ktor-serialization-kotlinx-json 3.0.3 Apache-2.0
ktor-serialization-kotlinx-jvm 3.0.3 Apache-2.0
ktor-serialization-kotlinx 3.0.3 Apache-2.0
ktor-serialization 3.0.3 Apache-2.0
ktor-server-cio-jvm 3.0.3 Apache-2.0
ktor-server-core-js 3.0.3 Apache-2.0
ktor-server-core-jvm 3.0.3 Apache-2.0
ktor-server-core 3.0.3 Apache-2.0
ktor-server-sse-js 3.0.3 Apache-2.0
ktor-server-sse-jvm 3.0.3 Apache-2.0
ktor-server-sse 3.0.3 Apache-2.0
ktor-server-websockets-jvm 3.0.2 Apache-2.0
ktor-sse-js 3.0.3 Apache-2.0
ktor-sse-jvm 3.0.3 Apache-2.0
ktor-sse 3.0.3 Apache-2.0
ktor-utils-js 3.0.3 Apache-2.0
ktor-utils-jvm 3.0.3 Apache-2.0
ktor-utils 3.0.3 Apache-2.0
ktor-websocket-serialization-js 3.0.3 Apache-2.0
ktor-websocket-serialization-jvm 3.0.3 Apache-2.0
ktor-websocket-serialization 3.0.3 Apache-2.0
ktor-websockets-js 3.0.3 Apache-2.0
ktor-websockets-jvm 3.0.3 Apache-2.0
ktor-websockets 3.0.3 Apache-2.0
lettuce-core 6.5.5.release MIT
logback-classic 1.5.13 EPL-1.0
LGPL-2.0-or-later
logback-core 1.5.13 EPL-1.0
LGPL-2.0-or-later
netty-common 4.1.118.final Apache-2.0
reactive-streams 1.0.4 MIT-0
reactor-core 3.6.6 Apache-2.0
slf4j-api 2.0.16 MIT
stax2-api 4.2.1 BSD-2-Clause
BSD-3-Clause
woodstox-core 6.2.4 Apache-2.0
Contact Qodana team

Contact us at [email protected]

@tiginamaria tiginamaria requested a review from Rizzen June 10, 2025 11:43
@tiginamaria tiginamaria marked this pull request as ready for review June 10, 2025 11:43
Rizzen
Rizzen previously requested changes Jun 10, 2025
@Rizzen
Copy link
Member

Rizzen commented Jun 10, 2025

@tiginamaria could you also rebase on latest develop? You have QD inspections because of little bit outdated branch

@tiginamaria tiginamaria force-pushed the tigina/parallel-nodes branch from b903bd5 to 62c9e78 Compare June 10, 2025 15:13
@tiginamaria tiginamaria force-pushed the tigina/parallel-nodes branch 2 times, most recently from 1e62ca8 to 3f71b34 Compare June 12, 2025 12:30
)

override suspend fun fork(): AIAgentContextBase {
TODO("Not yet implemented")
Copy link
Collaborator Author

@tiginamaria tiginamaria Jun 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I implement fork/replace for the DummyAIAgentContext? And why we actually need it (I don't see any functionality that blocks from using just AIAgentContext, except all nullable values, or I'm missing something)?

Copy link
Contributor

@ptitjes ptitjes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was not sure about the cast in the fork node. But apart from that LGTM.

@tiginamaria tiginamaria force-pushed the tigina/parallel-nodes branch from 9b9e1d1 to 8c63f49 Compare June 18, 2025 07:24
@tiginamaria tiginamaria force-pushed the tigina/parallel-nodes branch 3 times, most recently from 891baba to b78cc97 Compare June 23, 2025 17:09
Copy link
Collaborator

@Ololoshechkin Ololoshechkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tiginamaria I pushed a small change , please take a look :)

@Ololoshechkin
Copy link
Collaborator

@tiginamaria please add more tests for the AIAgentParallelNodesMergeContext methods (let's cover them)

@ptitjes ptitjes mentioned this pull request Jun 24, 2025
12 tasks
@tiginamaria tiginamaria force-pushed the tigina/parallel-nodes branch from fdd171a to a1a5630 Compare June 24, 2025 12:40
@tiginamaria tiginamaria merged commit 1b34911 into develop Jun 24, 2025
5 checks passed
@tiginamaria tiginamaria deleted the tigina/parallel-nodes branch June 24, 2025 13:01
* @param context The context to replace the current context with.]]
*/
override suspend fun replace(context: AIAgentContextBase) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a potential problem with this method that might confuse someone (it confused me initially, at least). From the method signature and according to KDocs it looks like the whole context will be replaced, but in fact it's not the case and only three properties are actually replaced.

private val mutableAIAgentContext = MutableAIAgentContext(llm, stateManager, storage)

override val llm: AIAgentLLMContext
get() = mutableAIAgentContext.llm
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, for all these properties there's no RW lock. Meaning, when the replace operation is in progress, it's still possible to read from these fields, potentially getting inconsistent data (although the chances are probably very low)

* Creates a copy of the current [MutableAIAgentContext].
* @return A new instance of [MutableAIAgentContext] with copies of all mutable properties.
*/
suspend fun copy(): MutableAIAgentContext {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not used

AIAgentLLMContext(
tools.toList(),
toolRegistry,
prompt.copy(),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's no need to unnecessary copy prompt and tools, these are already fully immutable

llm.writeSession {
model = OpenAIModels.Chat.GPT4o
updatePrompt {
prompt("best-joke-selector") {
Copy link
Contributor

@EugeneTheDev EugeneTheDev Jun 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This part wouldn't work. updatePrompt accepts PromptBuilder and in its lambda returns Unit. It is meant to add more messages to existing prompt. In this case a new prompt is created and returned, but since the lambda is Unit, this operation essentially has no effect and the prompt remains the same.

@Ololoshechkin Ololoshechkin mentioned this pull request Jul 14, 2025
14 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants