koog icon indicating copy to clipboard operation
koog copied to clipboard

Please upgrade the dependency version of kotlinx-datetime from 0.6.2 to 0.7.1

Open YangDai2003 opened this issue 4 months ago • 7 comments

Improve the compatibility with kotlin.time.Instant and kotlin.time.Clock

YangDai2003 avatar Sep 03 '25 18:09 YangDai2003

/**
 * This is a deprecated type alias for `kotlinx.datetime.Clock`.
 *
 * Before 0.7.0, this type was used to represent a clock in the `kotlinx.datetime` library.
 * However, in Kotlin 2.1.20,
 * the `kotlin.time.Clock` type was introduced and is now the preferred way to represent a clock.
 *
 * This type alias is kept for making sure the existing code that uses `kotlinx.datetime.Clock` compiles.
 * For ensuring binary compatibility instead of source compatibility,
 * see <https://github.com/Kotlin/kotlinx-datetime?tab=readme-ov-file#deprecation-of-instant>.
 */
@Deprecated(
    "This type is deprecated in favor of `kotlin.time.Clock`.",
    level = DeprecationLevel.WARNING,
    replaceWith = ReplaceWith("kotlin.time.Clock", "kotlin.time.Clock"))
public typealias Clock = kotlin.time.Clock

When datetime v0.7.0 or higher exists in the project, Koog will have compatibility issues due to this typealias.

YangDai2003 avatar Sep 03 '25 20:09 YangDai2003

#726 #727

adamglin0 avatar Sep 04 '25 23:09 adamglin0

When the application has the kotlinx-datetime library version that is less than 0.7.1, it crashes at runtime with this error:

 java.lang.NoSuchMethodError: No direct 
  method <init>(Ljava/lang/String;Lai/koog/prompt/executor/clients/anthr
  opic/AnthropicClientSettings;Lio/ktor/client/HttpClient;Lkotlin/time/C
  lock;ILkotlin/jvm/internal/DefaultConstructorMarker;)V in class 
  Lai/koog/prompt/executor/clients/anthropic/AnthropicLLMClient; or its 
  super classes (declaration of 
  'ai.koog.prompt.executor.clients.anthropic.AnthropicLLMClient' appears
   in /data/app/~~lkg4QDVldpi-pI2a0vafMQ==/dev.olek.lmclient.androidApp-
  NNRKrh5iHDxg8pT_BM3UCw==/base.apk)

OKatrych avatar Sep 07 '25 12:09 OKatrych

I get the same problem in v0.4.2.

crash log> java.lang.NoSuchMethodError: 'void ai.koog.prompt.executor.clients.openai.OpenAILLMClient.(java.lang.String, ai.koog.prompt.executor.clients.openai.OpenAIClientSettings, io.ktor.client.HttpClient, kotlin.time.Clock)'

open class OpenAiRemoteLLMClient(
    apiKey: String, settings: OpenAIClientSettings = OpenAIClientSettings(
        baseUrl = "https://.gree.com",
        chatCompletionsPath = "/baitong/chat/completions",
        embeddingsPath = "https://aiw.gree.com/openapi/v2/embeddings"
    ), baseClient: HttpClient = HttpClient { }.config {
        install(Logging) {
            level = LogLevel.ALL
            logger = object : Logger {
                override fun log(message: String) {
                    println(message)
                }
            }
        }
    }
) : OpenAILLMClient(apiKey, settings, baseClient)

fun createAiClient(apiKey: String): SingleLLMPromptExecutor {
    return SingleLLMPromptExecutor(
        OpenAILLMClient(
            apiKey = apiKey, settings = OpenAIClientSettings(
                baseUrl = "https://.gree.com",
                chatCompletionsPath = "/baitong/chat/completions",
                embeddingsPath = "https://aiw.gree.com/openapi/v2/embeddings"
            ), baseClient = HttpClient().config {
                install(Logging) {
                    level = LogLevel.ALL
                    logger = object : Logger {
                        override fun log(message: String) {
                            printLog(message)
                        }
                    }
                }
            })
    )
}

It can success in v0.4.1 ,failed in v0.4.2. I want to custom a executor,I use kotlinxDatetime-0.6.2 ,but OpenAILLMClient in sdk show inner function arg is kotlinx.datetime.Clock, in v0.6.2 only use kotlin.time.Clock.

1006245347 avatar Sep 16 '25 06:09 1006245347

I have the same issue. The build fails with "Caused by: java.lang.ClassNotFoundException: kotlinx.datetime.Clock$System" when adding kotlinx-datetime 0.7.1 into my project

geomagilles avatar Sep 17 '25 19:09 geomagilles

Until this gets fixed, you can bump the version to this version

implementation("org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compat")

This maintains compatibility with the apis koog uses aswell as newer 0.7.1 version.

PranavPurwar avatar Sep 20 '25 05:09 PranavPurwar

Hi everybody, thanks for your input!

Please feel free to track the issue's progress here: KG-544 Upgrade the dependency version of kotlinx-datetime from 0.6.2 to 0.7.1

aozherelyeva avatar Nov 12 '25 12:11 aozherelyeva