← BLOG

Engineering · Dec 2, 2026 · 4 min read

What if codemode used Lisp?

MS
Miguel Salinas
CTO, camelAI
What if codemode used Lisp?

Last weekend I fell down a rabbit hole thinking about the optimal language for agents to use codemode. Every harness has now adopted some form of codemode where the agent can write a script that uses tools instead of calling the tools directly. This leads to some pretty impressive results. Everyone has seemingly settled on javascript as the scripting language but what if we could do something way simpler?

In the spirit of DHH vibe coding in raw assembly I wanted to think about what a lower level more bare bones approach to codemode would be. What is the assembly equivalent for scripting? Probably something like wasm bytecode but that's way too verbose and token inefficient for something that's supposed to be used for virtually every tool call.

Ok so what else could we do? Well instead of parsing some javascript syntax into an AST before turning it into bytecode and then executing it in a VM why can't we just rip out the first step and write out an AST directly? Well it turns out this is basically LISP. LISP's syntax is extremely simple and easy to parse. In fact our first parser was ~100 lines.

I added arbitrary pausing and resuming in a few hundred more lines of code to add durability. At this point it felt like a no-brainer to replace javascript.

Then we had some models actually use it…

Small models were hit-or-miss. They wrote mostly correct code but would miss a closing paren or add an extra.

(count (filter (lambda (res) (get res "ok")) results))))))
;; SyntaxError: Unexpected extra ')'

Or they would close a block early on accident.

(let ((alerts (map (lambda (i)
  (if (> i.age_minutes 30)
    (if (not i.acknowledged)
      (let ((oncall (get-oncall (obj "service" i.service))))
        (post-slack (obj "channel" oncall.channel
                         "text" (concat "<" oncall.handle ": " i.title ">")))))
      nil)
    nil))
  incidents))
;; TypeError: map expects (map fn list)

Large models didn't have these issues but they did spend way more thinking tokens when writing lisp vs javascript.

Claude Haiku 5.5 passed both languages, spending 784 tokens on Lisp versus 181 on JavaScript, over 4x as many. DeepSeek V4.1 Flash needed 1,932 tokens on Lisp versus 323 on JavaScript. Nearly 2,000 tokens for a ten-line script.

Even if you discount the thinking tokens, the Lisp scripts themselves were consistently more tokens than the equivalent JS scripts.

Failed scripts and more burned tokens are not worth the implementation simplicity so we're sticking to Pi-Durable's built-in QuickJS in WASM for now. And we're looking forward to their new codemode that uses their own interpreter with pause/resume support.

CAMELRUN · HOSTED AGENT RUNTIME

Run your AI agents on camelRun.