Skip to content
AI Primer
workflow

Geoffrey Huntley demos an SBCL kernel that modifies itself while running

Geoffrey Huntley's experimental SBCL kernel uses LLM tool calls to add functions, test them and hot-reload passing changes. It saves revisions with rollback support; a fresh process reproduced a successful revision.

4 min read
Geoffrey Huntley demos an SBCL kernel that modifies itself while running
Geoffrey Huntley demos an SBCL kernel that modifies itself while running

TL;DR

  • A running Lisp application can acquire new functions through model tool calls, as developer Geoffrey Huntley demonstrated in his terminal demo.
  • The saved change survived a fresh SBCL process: his follow-up reports 21 fixed cases, 1,000 generated cases, rollback and restoration.
  • Durable restarts offer another route to self-editing software: badlogicgames says Pi Durable preserves in-progress work when code changes kill worker processes.

A deployed SBCL executable can still invoke compile and load. Huntley had already been experimenting with OCaml effects and MirageOS unikernels.

In-band function replacement

Huntley describes a small kernel with four operations:

  1. Ask a model for inference.
  2. Replace a function in memory.
  3. Test the function.
  4. Commit the change or roll it back.

Missing functionality can trigger an inference request to add it, allowing the application's outer layers to evolve from that kernel.

He had described the direction as actors that “repair the image (don't rebuild it),” with tooling designed for LLMs as programmers.

Snapshots and abort

The illustrated loop checks locked-p and takes a snapshot before evaluating the model's proposed form.

Common Lisp's restart-case provides named control-transfer paths. The sketch's abort clause explicitly restores the snapshot.

reverse-string and saved revisions

Huntley reported a complete mutation-and-recovery sequence:

  1. OpenAI inspected a running Steel Bank Common Lisp (SBCL) process and added reverse-string through a tool call.
  2. The caller checked 21 fixed inputs and 1,000 generated inputs, then saved the generation.
  3. A fresh SBCL process passed the same checks against the saved revision, the demo's strongest receipt.
  4. Rollback removed reverse-string while preserving the existing demo.
  5. Restoring the successful revision brought the function back.

Runtime tools

The initial world contains a hash-table-backed counter and a NONNEGATIVE-COUNTER safety check, visible in the terminal screenshot in his thread. The REPL advertises seven capabilities:

  • Inspect the world, definitions, state, goals and safety invariants.
  • Evaluate Lisp expressions and change functions or data.
  • Run the caller's goals and safety checks.
  • Handle recoverable errors using available restarts.
  • Inspect accepted revisions.
  • Roll back to an accepted revision on explicit request.
  • Abort a repair or resume a paused restart.

Actors and genetic algorithms

mikehostetler described the pattern as a self-driven actor with an LLM brain, progress snapshots and external invariants. He raised three distinctions:

  • Genetic algorithms optimize a measurement.
  • A multi-agent version would let independent actors operate on shared world state.
  • Classical AI could handle routine machinery, with LLMs handling exceptions and writing text instead of being queried on every turn.

Proofs and code reading

Huntley questioned the need to read implementations when the time is spent on proofs. In a separate, earlier post, badlogicgames said that “only people who can still read the code can understand this.”

Pi Durable on Android

badlogicgames is building pim with pim on his phone. He also demonstrated multiplayer on Android through an ngrok tunnel.

Reloading follows two paths:

  • Web UI: hot-module replacement.
  • Server and session workers: kill the processes and respawn them.

Pi Durable automatically resumes in-progress work after those process deaths, according to his explanation. The phone process runs as a foreground service that mostly waits for LLM responses.

Prototype status

Huntley described the project in a reply as still in the “I can't believe this actually works” phase. When asked for a name, he called it “bored on a plane; somewhere over the pacific ocean”.

He said he would put the code on GitHub after landing.

Further reading

Discussion across the web

Where this story is being discussed, in original context.

On X· 7 threads
TL;DR1 post
In-band function replacement1 post
Snapshots and abort1 post
Runtime tools1 post
Proofs and code reading2 posts
Pi Durable on Android4 posts
Prototype status2 posts
Share on X