Not sure if this is related <@U47AV9UM9>, but I ju...
# koog-agentic-framework
r
Not sure if this is related @rcd27, but I just upgrade to
0.5.3
and every toolcall fails when getting a result back. I was on
0.5.2-develop-20251106-0206
before and there it's all working fine... Does anyone have the same issue?
Copy code
Wrapped by: kotlinx.serialization.SerializationException: No tag in stack for requested element
	at kotlinx.serialization.internal.TaggedEncoder.popTag(Tagged.kt:165)
	at kotlinx.serialization.internal.TaggedEncoder.encodeString(Tagged.kt:75)
	at ai.koog.agents.core.tools.ToolResult$AsTextSerializer.serialize(ToolResult.kt:172)
	at ai.koog.agents.core.tools.ToolResult$AsTextSerializer.serialize(ToolResult.kt:153)
	at kotlinx.serialization.json.internal.AbstractJsonTreeEncoder.encodeSerializableValue(TreeJsonEncoder.kt:306)
	at kotlinx.serialization.json.internal.TreeJsonEncoderKt.writeJson(TreeJsonEncoder.kt:21)
	at kotlinx.serialization.json.Json.encodeToJsonElement(Json.kt:160)
	at ai.koog.agents.core.tools.SerialToToolDescriptionKt$asToolDescriptorSerializer$1.serialize(SerialToToolDescription.kt:175)
	at kotlinx.serialization.json.internal.AbstractJsonTreeEncoder.encodeSerializableValue(TreeJsonEncoder.kt:306)
	at kotlinx.serialization.json.internal.TreeJsonEncoderKt.writeJson(TreeJsonEncoder.kt:21)
	at kotlinx.serialization.json.Json.encodeToJsonElement(Json.kt:160)
	at ai.koog.agents.core.tools.Tool.encodeResult(Tool.kt:165)
	at ai.koog.agents.core.environment.GenericAgentEnvironment.processToolCall(GenericAgentEnvironment.kt:156)
	at ai.koog.agents.core.environment.GenericAgentEnvironment.access$processToolCall(GenericAgentEnvironment.kt:22)
	at ai.koog.agents.core.environment.GenericAgentEnvironment$processToolCall$1.invokeSuspend(GenericAgentEnvironment.kt)
	at _COROUTINE._BOUNDARY._(CoroutineDebugging.kt:42)
	at ai.koog.agents.core.environment.GenericAgentEnvironment$processToolCallMultiple$results$1.invokeSuspend(GenericAgentEnvironment.kt:166)
	at ai.koog.agents.core.environment.GenericAgentEnvironment.processToolCallMultiple(GenericAgentEnvironment.kt:163)
	at ai.koog.agents.core.environment.GenericAgentEnvironment.executeTools(GenericAgentEnvironment.kt:53)
	at ai.koog.agents.core.environment.AIAgentEnvironmentKt.executeTool(AIAgentEnvironment.kt:43)
r
What is the return type of a tool you using? Can you please share
data class
?
r
ai.koog.agents.mcp.McpTool.Result
🤔 1
Looks like it was introduced in this PR
I am able to reproduce it by adding a test in
McpToolTest
Copy code
@Test
fun `test encode result`() {
    val result = McpTool.Result(promptMessageContents = listOf(TextContent("Hello world")))
    val toolDescriptor = ToolDescriptor(
        name = "test-tool",
        description = "A test tool",
        requiredParameters = emptyList(),
        optionalParameters = emptyList()
    )
    val mcpTool = McpTool(
        mcpClient = Client(clientInfo = Implementation(name = "Test", version = "1.0")),
        descriptor = toolDescriptor,
    )
    val expected = mcpTool.encodeResult(result)

    // Not sure what the result should look like
    assertEquals(TODO("Whatever the expected value is"), expected)
}
I'd really appreciate a fix for this as this is a regression as each McpTool is now throwing this exception
👍 1
k
Thank you, Ruben!
r
@Konstantin - I figured out the issue. I've put up a PR here
👀 1
Btw - I also noticed that when I
publishToMavenLocal
(to test the fix locally), I see that the
a2a
package aren't under
ai.koog
but just under
koog
- but also the version doesn't get a
-SNAPSHOT
but is named
unspecified
Might be worth fixing that - unless there's another way to test the library change in an actual application locally
k
thank you for detecting the build issue. Regarding serialization, I am wondering if deserizlizer should be changed symmetrically to this
r
Will take a look
k
I guess, this is the test:
Copy code
@Test
fun `test encode result`() {
    val result = McpTool.Result(
        promptMessageContents = listOf(TextContent("Hello world"))
    )

    val expected = buildJsonObject {
        put("promptMessageContents", "Hello world")
    }

    val randomMcpTool = randomMcpTool()

    val serialized = randomMcpTool.encodeResult(result)
    assertEquals(expected, serialized)

    println(serialized)

    val decoded = randomMcpTool.decodeResult(serialized)

    assertEquals(expected = result, actual = decoded)
}
can we also move serialization test to
agents/agents-tools/src/commonTest/kotlin/ai/koog/agents/core/tools/serialization/McpToolTest.kt
?
r
You mean
ToolSerializationTest.kt
?
k
yep, a good name
Btw - I also noticed that when I
publishToMavenLocal
(to test the fix locally), I see that the
a2a
package aren't under
ai.koog
but just under
koog
- but also the version doesn't get a
-SNAPSHOT
but is named
unspecified
Can't reproduce it. When I run
./gradlew publishToMavenLocal
from the project root, a2a modules are correctly published with the right groupId and and version. But also I noticed that dokka was not run for a2a modules. Fixing that
r
yep, a good name
oh, I thought you wanted me to move it to that file
@Konstantin - I'm struggling with the
decodeResult
part, as the encoding relies on the
textForLLM
function, but there's no way back
k
Let me have a look
r
Just pushed a proposal
gratitude thank you 1
@Konstantin I'm struggling with the CI/CD pipeline. Not sure I understand the errors but they don't seem related to my changes
a
Looks like this is indeed a flaky test. I’ve manually triggered another CI run, we’ll investigate the flaky test
I’ve created PR with
McpTool
fix https://github.com/JetBrains/koog/pull/1128
r
Thank you. I appreciate it
👍 1