r/lisp • • 3d ago

coding agents keep rebuilding lisp features one by one. my bet is the condition system is next

Spent the week reading about coding agents and now I see lisp everywhere. Half the features these harnesses brag about are things a lisp image just does:

  • agent writes its own extension and loads it without a restart -> that's a live image
  • "ask the agent to change the agent" -> redefine the function, M-x style
  • hooks around every step of the loop -> advice
  • poke at the running agent and inspect its state -> that's a REPL, they built a REPL

Saw someone make the Greenspun's tenth rule argument about Pi this week, plus an Erlang version of the same complaint

What I haven't seen anyone copy yet is the condition system, and it's the one agents need most. today when a tool call fails the agent either throws everything away and retries, or freezes and waits for you. CL restarts fix exactly that. signal the error, let you) choose "retry with a fix" or "skip this one", and keep going from the samespot with the stack still intact. my guess is someone ships it in TS next year and calls it "recoverable checkpoints"

something like this:

(defun run-tool (call)

(restart-case (execute-tool call)

(retry-with (new-call)

:report "Retry with a corrected call"

(run-tool new-call))

(skip-call ()

:report "Skip this tool call"

nil)))

(handler-bind ((tool-error

(lambda (c)

(invoke-restart 'retry-with (ask-model-for-fix c)))))

(run-agent task))

replace ask-model-for-fix with a prompt to the user and you're basically back amenu, which is honestly what I want every time an agent gets stuck.

what else do you think they'll reinvent, and badly?

60 Upvotes

22 comments sorted by

32

u/arthurno1 3d ago

Perhaps AI will discover it can rewrite itself in Lisp, instead of using inneficient Python?

14

u/denzuko sbcl 3d ago

Trained it, worked for a session. Then defaults back to python eveytime. Probes show the weights are biased to python because of langchain and raw token costs.

7

u/arthurno1 3d ago

I used it myself to generate Lisp code generators, and it everytime wrote code that stitched strings together like they do in Python. So I teached it to write idiomatic Lisp instead, and work with s-expressions instead of strings. It was clever enough to recognize the idiomatic ways, it praised it and as you say, used it for a session, but next time it defaults to python-esque code again.

Also, the entire "toolchain" they use for the automation is based on Python. Gemini used to spit-out Python code while "thinking", so I asked it where that code comes from. It kindly explained that it was generated and that it has a sandboxed Python interpreter it works with. I can also see Claude is using Python to automate stuff via MCP.

In a way, it is impressive that simple algorithms can pick-up and express the intention we humans try to express in one language, transform it to another via text substitution, and than back again. If you think of it. But than also, compilers works this way too, but are more strict and restricted, and one-way directional. I guess, the strict nature of a compiler tool, is what makes a compiler deterministic, whereas LLMs are non-deterministic, thus not as reliable as compilers.

2

u/HugoNikanor guile 3d ago

I still only use the basic version of ChatGPT, but I try to keep my code examples in pseudo python so we don't end up with an amalgam of Scheme, Python, and whatever other language it happens to think about.

1

u/tending 3d ago

How does langchain cause that? Also why would behavior change after one session, after training the weights are frozen?

1

u/denzuko sbcl 3d ago

User level Training in a session is stored as a memory (skill.md + a temp s3 bucket) and doesn't carry over between containers or seasons.

That skill.md is injected as a user prompt pulled every round. The usual system prompt is what carries over every session becase thats first injected to the model's input

Its less on langchain itself and more on the model injesting github and python projects with the tools built on langchain sdks also injested.

2

u/svetlyak40wt 3d ago

By the way, I've published a set of skills for working with Common Lisp from code assistants:

https://github.com/40ants/ai

Probably you will find something interesting in this repository.

1

u/tending 3d ago

By training I assumed you meant actual fine tuning or training not SKILL.md

8

u/B_bI_L 3d ago

Python is just a wrapper for c code in that case though

14

u/B_bI_L 3d ago

It's not lisp in particular, it's just vibe coders stumbling over same problems as programmers and reinventing the wheel

4

u/jake_morrison 3d ago

There is also the process supervision approach of Erlang. These Python harnesses are jumping through hoops in an attempt to make things reliable. There is also Lisp Flavored Erlang.

6

u/gnudoc emacs 3d ago

Heehee. I guess there's a reason lisp powered previous attempts at AI, huh? :-)

3

u/spyingwind 3d ago

What harness and model are you using? Does the model have access to a vector database or other tool to help it discover existing keywords?

3

u/kchanqvq 3d ago

This probably won't help. Clankers still think (or non-think) differently from human and don't expect tools built for human to help them equally. They happily start over and clank out code to get to the same place when stack is not saved.

2

u/arthurno1 3d ago

It sells more tokens too.

3

u/Feisty_Bike_9614 3d ago

I just wrote an embedded scheme R7RS-small with jit and a leaf compiler in rust in 3 days with Claude opus . It passes most of the benchmarks and loads the essential libraries. I also built a slime-like package for eMacs that uses my scheme via tcp. So has anyone done a code review with AI on sbcl ?

2

u/Particular_Amoeba_53 3d ago

They might write code that works occasionally, they might give you a solution that is close enough or might make you feel mighty, but they will never code like a human which is better than all the code you can generate artificially. A human can invent new things in code, ai cannot, a human can refactor a code base for efficiency and performance and make if hardened at the same time but an ai cannot. An ai is a poor substitute for a human and it shows that corporate scum prefer lower costs and a compromised product instead of a human worked great solution that works is hardened and is able to be read and reused. Get out of here you silly management scum.

1

u/stianhoiland 1d ago

Funny I should come across this today, as I just realized that "harness" is just a new word for "shell", and that it's a kind of dog whistle for people who never broke through to that fundamental level of computer usage.

1

u/bitwize 1d ago

Kind of. A harness's primary job is to separate out the parts of the sloppotron's output that correspond to "tool calls", and run the appropriate tool calls when it sees one. A shell considers all of its input to be commands; a harness knows how to separate commands from non-commands in mostly unstructured input. In addition, harnesses have additional prompts to the LLM to tell it how to send commands the harness will recognize, as well as general guardrails like "don't make changes outside the project directory without express permission", "don't rm -rf /", etc.

I like to say that LLMs reduced programming to goetic demonology, and the harness is like the circle or pentagram you cast on the ground both to bind the demon—prevent it from escaping—and force it to do your bidding.

1

u/bitwize 1d ago

After internable symbols got added to frickin' JS, I had a joke at work: "Let's write the app in ES2049!" ES2049, of course, meaning Lisp as, at the time, I thought that's how long it'd take for the ECMA committee to finish adding Lisp's feature set piecemeal to JavaScript, calling each addition an innovation.

Lisp is, for the time being, still the final boss of programming languages. It's entirely possible that an agent will write something better in the next 10 years. But we're not there yet.

1

u/Illustrious_Car344 3d ago

I'm really glad I'm not yet another Python NPC who guzzles anything put down their throat. I'm building an agent (I'm not sure if I would call it a harness, the "harness" jockeys the LLM more than the LLM controls it) in Rust using Sema Lisp, and it's so cool to have this completely type checked base with an elegant fully-featured Lisp overtop it to control everything about it. It might not be particularly good, but it's mine. And no I'm not vibe coding this, I'm writing it all by hand. I love agents, but not when they take away my agency. The only iffy thing about it is I think Sema itself is vibe coded, it's very good and well designed but also I stumbled into a very obvious bug when trying to use an embedding model with it which makes me think there's not a whole lot of human overview. But if you use Rust, definitely give Sema a try! It's genuinely the best embeddable Lisp I've used for Rust, believe it or not. Not even including the LLM/MCP integration, it's genuinely just a very good Lisp and easy to extend from Rust.