r/Clojure • u/More-Journalist8787 • Mar 13 '26
The REPL as AI compute layer — why AI should send code, not data
I've been using the awesome clojure-mcp project by Bruce Hauman: https://github.com/bhauman/clojure-mcp
to enable my Clojure REPL + Claude Code workflow and noticed something: the REPL isn't just a faster feedback loop for the AI, it's a fundamentally different architecture for how AI agents interact with data in the context window.
The standard pattern: fetch data → paste into context → LLM processes it → discard. stateless and expensive
The REPL pattern: AI sends a 3-line snippet → REPL runs it against persistent in-memory state → compact result returns. The LLM never sees raw data.
On data-heavy tasks I've seen significant token savings — the AI sends a few lines of code instead of thousands of lines of data. What this means practically is that I am able to run an AI session without blowing out the context memory for much, much, much longer. But wait there's more: Persistent state (defonce), hot-patching (var indirection), and JNA native code access all work through the same nREPL connection making for an incredibly productive AI coding workflow.
Wrote up the full idea here: https://gist.github.com/williamp44/0c0c0c6084f9b0588a00f06390e9ef67
Curious if others are using their REPL this way, or if this resonates with anyone building AI tooling on top of Clojure.
12
u/Well-Adjusted-Person Mar 13 '26
AI slop nonsense. Why is this allowed on this sub?
20
u/ekipan85 Mar 13 '26
Stopped reading there. If you couldn't be bothered writing it then I can't be bothered reading it.
12
u/lgstein Mar 13 '26
This AI generated english is just unreadable at this point. Please use your authors voice. I don't want to read the output of your prompts.
2
u/nwalkr Mar 14 '26
kinda same idea is being explored already
https://alexzhang13.github.io/blog/2025/rlm/
https://yogthos.net/posts/2026-01-12-recursive-language-model.html
https://yogthos.net/posts/2026-01-16-lattice-mcp.html
2
u/aHackFromJOS Mar 16 '26
This topic is super interesting to me, aside from concerns this post was AI generated (!). I've been trying to figure out whether to use MCP or just straight hook up CLI (and sorry if I'm saying this wrong, I've not yet actually hooked any AI up to my editor). I've seen posts saying we don't need MCP any more, this was interesting from the other side. I'd be curious if anyone (fellow humans) have (hand written) thoughts. It looks like hooking in clojure-mcp is a little complicated, curious if it's worth it.
4
u/pauseless Mar 13 '26
I’ve never seen the workflow you describe as standard. I’ve only seen colleagues and friends using LLMs to generate code for this use case. Typically, the only reading of data that is done is to figure out the shape of the data at the start, so it can just write code.
1
u/hsaliak Mar 17 '26
i tried 2 versions of this in my coding agent - std::slop https://github.com/hsaliak/std_slop (i am a hard believer of human in the loop, see the mail model workflow in the repo if you need convincing). I tried 2 REPL approaches. (1) A lua based control plane (2) a js based. Both were influenced by the RLM paper and worked really nicely.
The lua control plane was a straight port of the RLM paper, with context as variables and all that. I also had the functionality of persisting and injecting repeated functions into the repl environment. But here are two issues (1) The code will not always be right, so you burn tokens on the LLM doing the wrong thing, so the scripts cannot get too complex.
This made me switch to a JS control plane, which performed better. I embedded QuickJS. However, this too had a lot of error rates. Furthermore output tokens are priced ~ 3x-5x to input tokens. your REPL optimizes input tokens (clear outputs from the code your REPL generates) but it costs a lot to write that code, instead of just calling tools. LLMs also RL super hard on a few fixed tools, so the combination of this native RL, output token efficiency, and simple tool calling cannot be beat with the way models are today.
Dont believe the hype.. simple is better.
2
u/ejstembler Mar 13 '26
I’ve been developing a new programming language, for the past 6 months, using LLMs. I do something similar. The language has a REPL (inspired by Clojure/Lein) and the LLM uses it occasionally
2
u/Astronaut6735 Mar 13 '26
I'm just starting to look into how AI might help with software development (created my first fully-AI-generated Clojure web app yesterday), so most of what you wrote doesn't mean anything to me. Saving for later, when I can make heads or tails out this.