JetBrains Open Sources KotlinLLM: LLM-Backed Runtime Logic for Compiled Kotlin
Key Takeaways
- ▸KotlinLLM generates Kotlin source code at development time via Smart macros, avoiding costly runtime LLM calls while keeping behavior explicit and reviewable in code review
- ▸The dual API—`asLlm<F, T>()` for type-safe data conversion and `mockLlm<T>()` for auto-generating test doubles—both backed by LLM-generated code that runs as ordinary Kotlin
- ▸Unlike prior LLM runtime systems (primarily targeting interpreted languages like Python), KotlinLLM addresses compiled, statically-typed languages, filling a gap in production AI tooling
Summary
JetBrains has open-sourced KotlinLLM, a research prototype that enables developers to delegate runtime logic to large language models directly from Kotlin code. Implemented as an IntelliJ IDEA plugin, KotlinLLM introduces "Smart macros"—a language feature that generates Kotlin source code at development time based on runtime scenarios, eliminating the need for runtime LLM calls, external agents, or separate AI services.
The plugin provides two primary Smart macro APIs: asLlm<F, T>() for converting unstructured data into typed Kotlin values, and mockLlm<T>() for generating stateful test doubles. What distinguishes KotlinLLM is its solution to a fundamental trade-off in production AI systems: direct runtime LLM calls are slow, costly, and non-deterministic, while external agent workflows keep generated logic outside the codebase where it's harder to review and test. KotlinLLM persists generated code as ordinary Kotlin source files that can be committed, reviewed, and tested like any other code.
JetBrains tested the approach on two real-world Kotlin/JVM projects. The adapted Spring Petclinic Kotlin demonstrated that 24 out of 24 application scenarios could be completed after Smart macro evolution, with a 100% hot-reload success rate and minimal runtime overhead (~1%). A second proof-of-concept analyzed GitHub issue data across 30,000+ issues, achieving approximately 0.89 recall on beginner-friendly issue labels. Released under the Apache License 2.0, KotlinLLM includes the IntelliJ plugin prototype, runnable example projects with committed generated sources, and supporting documentation from a KotlinConf 2026 presentation.
- Real-world testing on Spring Petclinic and GitHub Issue Radar demonstrates feasibility, with 100% scenario completion rates and strong recall metrics with minimal performance overhead
- Available under Apache License 2.0 as a complete open-source project, including plugin source, runnable examples, and documentation
Editorial Opinion
KotlinLLM represents a meaningful advance in bringing LLM capabilities to production Kotlin applications without traditional cost-latency trade-offs. By persisting generated code as actual source files, JetBrains solves a critical problem: making LLM-backed features reviewable, testable, and reproducible—essential for enterprise adoption. The focus on compiled, statically-typed languages fills a notable gap, as most prior work has targeted Python and other interpreted languages. This open-source release could establish a template for how other language communities approach runtime LLM integration.



