NEWS / 0182

AI & ML

JetBrains Releases KotlinLLM as Open Source for Runtime Code Generation

Published
Aug 03, 2026
Views
619

JetBrains has made KotlinLLM open source, allowing Kotlin developers to create and maintain runtime logic without external model calls.

JetBrains Releases KotlinLLM as Open Source for Runtime Code Generation

JetBrains has introduced KotlinLLM as an open-source project, providing Kotlin/JVM developers with a research prototype that allows for the dynamic generation of application logic during runtime, while maintaining this logic as conventional, reviewable source code.

Originating from JetBrains Research, KotlinLLM was developed by Anastasia Birillo and Stanislav Sandler. It aims to resolve a persistent challenge: enabling Large Language Models (LLMs) to handle complex logic without requiring constant reliance on live model calls during application execution.

This tool operates as a plugin for IntelliJ IDEA and introduces what the team refers to as “Smart macros.” These macros enable Kotlin function calls to generate their own code bodies. Currently, the public API offers two macros: asLlm<F, T>() and mockLlm<T>(). The former takes in unstructured or semi-structured data and produces a typed Kotlin value (like a data class, enum, or list), while the latter generates a stateful implementation of an interface, effectively functioning as a test double without the need for manual creation.

Typical call sites in Kotlin remain unchanged; however, KotlinLLM operates differently. Rather than calling a model every time the function is invoked, it generates actual Kotlin source code upon encountering a scenario for the first time, subsequently reusing this code. This eliminates additional latency and ensures reproducible output, as the compiled code resides within the repository.

Mitch Ashley, VP at The Futurum Group, emphasizes the benefits of this approach: “A model call in the request path has no SLA. Generating the code once and committing it places that logic back under change control, providing teams with a diff, a test, and a rollback option rather than a prompt to trust.”

This differentiation is vital, particularly given the trade-offs associated with existing methods. Directly calling an LLM for each request is both slow and non-deterministic, making apps overly dependent on external services during runtime. Other approaches often remove logic from the codebase, complicating review and testing processes. While previous research efforts such as byLLM, nightjar, and Healer primarily targeted interpreted languages like Python, Kotlin’s compiled and statically typed nature has largely been overlooked.

KotlinLLM has been constructed with three key characteristics in mind: explicitness, persistence, and portability. Code generated through this tool is explicit, allowing reviewers to understand that a feature relies on an LLM just by examining the call site. The generated behavior is persistent, saved as source code rather than only within a runtime context. Lastly, it’s portable, meaning that once the plugin is disengaged, the created code runs as standard Kotlin.

Ashley highlights the advantage of explicitness for teams that often face review bottlenecks. “Self-evidencing code is how teams mitigate verification debt,” he notes. “A reviewer can see that the call site is model-backed and precisely what it has produced. Teams deploying AI-generated logic need to ensure that reviewers can easily verify it.”

Testing has been conducted using two projects. An adapted version of the Spring Petclinic in Kotlin featured 18 calls to asLlm and successfully handled all 24 application scenarios after adapting to the Smart macros, achieving a perfect hot-reload success rate. The additional overhead from compilation and redefinition was approximately 1% at runtime, making the tool feasible for practical implementation. A synthetic project called GitHub Beginner Issue Radar analyzed real issue data from 20 repositories, comprising over 30,000 issues, and achieved around 0.89 recall against ground-truth beginner labels.

This isn’t the first effort to incorporate LLMs into dynamic logic. A University of Michigan initiative known as byLLM attempted something similar for Python, utilizing a compiler that interprets the semantic intent from code to formulate specific prompts. This project has already garnered over 14,000 downloads in a month since its open-source release, indicating a strong demand for tools that allow developers to gain ownership over AI-generated logic instead of simply calling it through an API.

The KotlinLLM is openly available under the Apache License 2.0 and includes the IntelliJ plugin, the Smart macro API, and runnable example projects—complete with committed generated sources from both test cases—allowing anyone to view and execute the LLM's output as regular Kotlin. JetBrains has also released a recording of their KotlinConf 2026 presentation along with a detailed technical write-up outlining the design and evaluation process.

Despite its strengths, JetBrains acknowledges that KotlinLLM is still a research prototype, inviting feedback at this stage. The team encourages users to implement it in real Kotlin/JVM projects, reporting issues or unexpected behaviors, and submitting pull requests with practical examples. They are particularly interested in identifying scenarios where asLlm and mockLlm excel, as well as where they fall short.

For teams venturing into agentic AI within their development frameworks, KotlinLLM holds potential not just for what it currently offers, but for setting a precedent of incorporating LLM-generated logic directly into the codebase, moving away from reliance on an API that demands trust with every invocation.

Source: Tom Smith · devops.com

Discussion

Sign in to join the discussion.