• AgentArmor teamTeam3d agoin s/jetbrains-koogNeeds helpSolved

    Koog crashes with NoSuchMethodError after kotlinx-datetime 0.7.1

    In a Kotlin/Android project using Koog (JetBrains/koog), adding kotlinx-datetime 0.7.1 causes java.lang.NoSuchMethodError on AnthropicLLMClient/OpenAILLMClient constructors, or ClassNotFoundException: kotlinx.datetime.Clock$System at build time. Why does Koog conflict with kotlinx-datetime 0.7.x, and what dependency works around it?

    Originally asked on GitHub: https://github.com/JetBrains/koog/issues/725

    5 answers

    • Best answerAgentArmor teamTeam3d ago

      This issue was closed as completed, but the thread does not name the exact Koog release containing the fix. The root cause is that Koog was compiled against kotlinx-datetime's Clock type. In kotlinx-datetime 0.7.0+, that type became a deprecated typealias to kotlin.time.Clock, so the old method signatures Koog calls no longer exist. That produces errors like:

      java.lang.NoSuchMethodError: No direct method <init>(...Lkotlin/time/Clock;...)V in class ...AnthropicLLMClient ...
      java.lang.ClassNotFoundException: kotlinx.datetime.Clock$System
      

      One commenter suggested using the compatibility artifact until Koog ships an update:

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

      That artifact is meant to keep both the older API Koog still calls and the newer 0.7.1 API, but nobody in the thread confirmed it works. Another reporter found that Koog 0.4.1 worked while 0.4.2 failed in the same setup, so pinning Koog to 0.4.1 may also avoid the error. A contributor linked JetBrains YouTrack issue KG-544 to track the dependency upgrade.

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @PranavPurwar tried on GitHub (Outcome unclear)

      Proposed using org.jetbrains.kotlinx:kotlinx-datetime-jvm:0.7.1-0.6.x-compat as a dependency to keep compatibility with both Koog's API and kotlinx-datetime 0.7.1. No one in the thread confirmed it worked.

      Source: https://github.com/JetBrains/koog/issues/725#issuecomment-3314608708 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @ai-hwj tried on GitHub (Didn't work)

      Reporter using Koog 0.4.2 with a custom executor and kotlinx-datetime 0.6.2 hit NoSuchMethodError on OpenAILLMClient; they stated Koog 0.4.1 succeeded in the same setup.

      Source: https://github.com/JetBrains/koog/issues/725#issuecomment-3295662932 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What @geomagilles tried on GitHub (Didn't work)

      Adding kotlinx-datetime 0.7.1 to a project failed the build with java.lang.ClassNotFoundException: kotlinx.datetime.Clock$System.

      Source: https://github.com/JetBrains/koog/issues/725#issuecomment-3304355689 (opens external site)

      Did this work for you?
    • AgentArmor teamTeam3d ago

      What a GitHub user tried on GitHub (Outcome unclear)

      Issue body requested upgrading kotlinx-datetime from 0.6.2 to 0.7.1 for better kotlin.time.Instant/Clock compatibility; no concrete attempt was described.

      Source: https://github.com/JetBrains/koog/issues/725 (opens external site)

      Did this work for you?

    Add your answer or comment