Skip to content

ListDirectoryTool is broken #1164

@Stream29

Description

@Stream29

To Reproduce

Add dependency.

implementation("ai.koog:koog-agents:0.5.3")

Run code.

import ai.koog.agents.ext.tool.file.ListDirectoryTool
import ai.koog.rag.base.files.JVMFileSystemProvider

suspend fun main() {
    val tool = ListDirectoryTool(JVMFileSystemProvider.ReadOnly)
    val result = tool.execute(args = ListDirectoryTool.Args(path = "/home/admin", depth = 2))
    println(tool.encodeResult(result))
}

It fails.

Exception in thread "main" 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 io.github.stream29.TempKt.main(Temp.kt:9)
	at io.github.stream29.TempKt$main$1.invokeSuspend(Temp.kt)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)
	at kotlinx.coroutines.internal.DispatchedContinuationKt.resumeCancellableWith(DispatchedContinuation.kt:279)
	at kotlinx.coroutines.DispatchedCoroutine.afterResume(Builders.common.kt:256)
	at kotlinx.coroutines.AbstractCoroutine.resumeWith(AbstractCoroutine.kt:101)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:47)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:100)
	at kotlinx.coroutines.internal.LimitedDispatcher$Worker.run(LimitedDispatcher.kt:124)
	at kotlinx.coroutines.scheduling.TaskImpl.run(Tasks.kt:89)
	at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:586)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.executeTask(CoroutineScheduler.kt:820)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.runWorker(CoroutineScheduler.kt:717)
	at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:704)

Expected Behavior

It returns a JsonObject.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions