JetBrains open-sources runtime LLM macros for Kotlin
JetBrains Research released KotlinLLM under Apache 2.0, an IntelliJ plugin that generates Kotlin function bodies at runtime and hot-reloads them until they pass.
Macros whose bodies are written by a model
JetBrains Research published KotlinLLM on 31 July, an IntelliJ IDEA plugin released under the Apache 2.0 licence that lets developers declare Kotlin functions and leave the implementation to a language model at runtime. Two APIs carry the idea: asLlm<F, T>(from, hint) for converting between types, and mockLlm<T>() for producing an implementation of an interface on demand.
The mechanism is unusual. The plugin scans a project for macro call sites, generates bootstrap code, then runs the program under the Java Debug Interface. When generated logic fails to handle a real scenario, a runtime breakpoint captures the actual values in play, an LLM agent rewrites the code against that evidence, and the class is recompiled and hot-reloaded through JVM class redefinition before execution is retried.
Costs are paid once per scenario
Because the loop writes real Kotlin source, the output is ordinary code that can be deployed without a model dependency at runtime. Scenarios already covered trigger no further model call, so there is no recurring latency or token cost on paths the system has seen before — a departure from agent designs that consult a model on every invocation. In a test on the Spring Petclinic sample application, JetBrains reported 24 of 24 scenarios completed and hot reload succeeding every time. The team labels the project a research prototype and explicitly does not recommend it as a production runtime.
Why it matters
Most coding-agent tooling operates before the program runs: it reads repositories, proposes diffs and waits for tests. KotlinLLM inverts that by using live execution state as the specification, which sidesteps the hardest part of code generation — inferring intent from static context — and gets ground truth from the debugger instead. Whether the pattern generalises beyond the JVM's unusually good hot-reload and debugging facilities is unresolved, but as an Apache-licensed reference implementation from the company that builds Kotlin, it gives the agent-infrastructure community something concrete to test against the current diff-and-test orthodoxy.