AI Agent in 100 Lines of Lisp: Minimal Code Reveals the True Nature of Intelligent Agents
AI Agent in 100 Lines of Lisp: Minimal…
100 lines of Lisp strips AI Agents to their core, revealing that the ReAct loop is simpler than you think.
A viral Hacker News project implements a complete AI Agent in just 100 lines of Lisp, demonstrating that the ReAct (Reasoning + Acting) loop at the heart of frameworks like LangChain is fundamentally simple. The article explores why Lisp's homoiconicity makes it ideal for Agent logic, breaks down the key modules in a minimal implementation, and draws three lessons: understanding principles beats mastering frameworks, transparency beats black-box abstractions, and minimalism has real limits in production.
When AI Agents Meet Ancient Lisp
In an era where AI Agent frameworks multiply endlessly — each demanding massive dependency libraries and complex abstraction layers — a thought-provoking project has sparked widespread discussion on Hacker News: a fully functional AI Agent implemented in just 100 lines of Lisp code.
The core value of this project isn't to replace mature frameworks like LangChain or AutoGPT. Rather, it reveals the essence of AI Agents: the core logic of an Agent is actually far simpler than we think. Strip away the engineering wrappers, error handling, and edge cases, and the skeletal code for an agent that can reason, invoke tools, and iterate to a solution becomes surprisingly compact.
Why Lisp?
Choosing Lisp to implement an Agent is no accident. Lisp (List Processing) was invented by John McCarthy in 1958, originally designed for artificial intelligence research — a fact often forgotten today. Throughout the 1970s and 80s, Lisp was virtually synonymous with AI research, spawning dedicated Lisp workstations (such as Symbolics and LMI) and nurturing a rich early AI tooling ecosystem. Common Lisp and Scheme are its two major modern dialects, with the former still active in industrial applications. This historical connection makes implementing an AI Agent in Lisp feel less like a novelty and more like a civilizational homecoming.
Lisp has several features that naturally suit the expression of Agent logic:
- Homoiconicity (Code as Data): In Lisp, code and data share the same structure (S-expressions, i.e., nested lists). This means a program can generate and modify its own code just like manipulating ordinary data. Dynamically generating, modifying, and executing logic becomes remarkably natural — exactly what an Agent needs when handling tool calls and reasoning chains. Tool call parameters and intermediate reasoning results can all flow seamlessly through the same structure, with no need for extra serialization and parsing layers.
- Powerful Macro System: Built on homoiconicity, macros allow you to construct domain-specific languages (DSLs) with minimal code, expressing Agent control flow elegantly and concisely.
- Interactive Development (REPL): Supports rapid iteration and debugging, making it easy to observe Agent behavior in real time.
The Essence of an Agent: A Simple Loop
Regardless of implementation language, the core logic of a modern LLM Agent can be reduced to a single loop:
- Receive the user's goal: Define what the Agent needs to accomplish.
- Call the large language model: Send the current context (conversation history, available tool descriptions, observations) to the LLM.
- Parse model output: Determine the model's intent — answer directly, or invoke a tool.
- Execute tools and collect results: If a tool call is needed, execute it and feed the result back to the model.
- Iterate: Repeat until the model decides the task is complete and outputs a final answer.
This ReAct (Reasoning + Acting) loop is the heart of the vast majority of Agent frameworks. The ReAct framework was proposed by Google Research in 2022 (paper title: ReAct: Synergizing Reasoning and Acting in Language Models). Its core idea is to have the LLM perform explicit reasoning (Reason) before generating an action (Act), then feed execution results back as observations (Observation) to close the loop. This paradigm has been widely adopted by mainstream frameworks like LangChain and AutoGPT, becoming the cornerstone of modern Agent architecture. The reason 100 lines of Lisp can implement a complete Agent is precisely because it captures this essential loop without falling into the trap of over-engineering.
What's Inside Those 100 Lines
While specific implementations vary, a minimal Agent like this typically contains the following modules:
- LLM Communication Layer: Wraps HTTP calls to OpenAI or other model APIs, handling JSON serialization and deserialization.
- Tool Registry and Dispatcher: Defines functions the Agent can call (e.g., web search, calculator, file I/O) and injects their descriptions into the prompt.
- Main Loop Controller: Implements the ReAct loop and manages conversation state.
- Output Parser: Extracts tool-call intent and parameters from the model's text output.
In Lisp, these modules can be written extremely compactly thanks to the language's expressive power. Tool definitions and invocations can be expressed almost directly as list structures, eliminating the boilerplate code found in other languages — what takes dozens of lines in Python or Java often fits in three to five lines of Lisp S-expressions.
Three Lessons from Minimalism
Lesson 1: Understanding Principles Matters More Than Mastering Frameworks
The most valuable insight from this project is: deeply understanding how Agents work is more important than being proficient with any particular framework. When developers are accustomed to building Agents through high-level abstraction frameworks, it's easy to mystify the process — to assume that a complex tech stack is required.
Those 100 lines clearly demonstrate: an Agent's intelligence comes almost entirely from the underlying large language model. The framework code is merely doing "glue" work — connecting user intent, tool capabilities, and model reasoning. For beginners, hand-writing a minimal Agent from scratch is the most effective way to understand the entire LLM Agent development stack.
Lesson 2: The Real Value of Controllability and Transparency
Heavyweight frameworks are feature-rich, but they introduce a black-box problem: when Agent behavior goes wrong, developers often struggle to tell whether the issue lies in their own code, the framework's abstraction layer, or the model itself. This phenomenon is known in software engineering as a "Leaky Abstraction" — underlying details inevitably pierce through abstraction layers, leaving developers who don't understand those fundamentals helpless. In production, an Agent behaving unexpectedly could stem from subtle differences in prompt templates, the framework's built-in retry logic, tool call serialization issues, or the inherent non-determinism of the model — multiple layers of abstraction make root-cause analysis extremely difficult.
By contrast, a self-implemented Agent at the hundred-line scale offers complete transparency. Every line of code is under your control, making debugging and customization straightforward. For research exploration or production scenarios with strict reliability requirements, this kind of controllability is often more valuable than the convenience of off-the-shelf frameworks.
Lesson 3: Acknowledge the Limits of Minimalism
Of course, we should also be objective about the limitations. A 100-line Agent is an elegant "teaching model," still quite a distance from production readiness. It typically lacks:
- Robust error handling and retry mechanisms
- Long-term memory and context management
- Multi-agent collaboration capabilities
- Observability and logging
- Security sandboxing (especially when executing tool calls)
These are exactly the reasons mature frameworks exist. A minimal implementation demonstrates core logic; engineered frameworks solve the problems of scaling to production — the two are not contradictory, but complementary.
The Philosophy of Small and Beautiful
This project resonates with a time-honored principle in software engineering: don't introduce complexity when a simple solution will do. This principle is sometimes called the engineering counterpart of Occam's Razor, and is a modern echo of the Unix philosophy of "do one thing well." In the AI Agent space — overhyped and overrun with frameworks — a 100-line Lisp implementation serves as a sobering reality check.
It reminds us: genuine technical understanding comes from touching the fundamentals firsthand, not from stacking abstractions. For engineers who want to truly master AI Agent development, rather than diving headfirst into the documentation of a massive framework, consider spending an afternoon implementing a hundred-line mini Agent in a language you already know. When you write that core loop yourself, the Agent ceases to be a mysterious black box and becomes a logically transparent tool you can shape freely.
That, perhaps, is the greatest value of projects like this.
Related articles

From Chat to Agent: Automating Your Entire Business Workflow with AI Agents
Veteran AI practitioner Remy breaks down the leap from chat models to AI agents: how agents work, the three pillars of context, tools, and skills, MCP connections, and hands-on architecture to make you a 100x employee.

Understand Anything: The AI Skill That Turns Code into Interactive Knowledge Graphs
Understand Anything is a high-star open-source GitHub skill that runs static analysis on any codebase and generates interactive knowledge graphs. It supports Claude Code, Cursor, Copilot and other agents, letting engineers ask questions in natural language with path references.

Kimi K3 Released: How a 2.8 Trillion Parameter Open Model Reshapes AI Cost-Effectiveness
Moonshot AI unveils Kimi K3: a 2.8 trillion parameter, 1M context, natively multimodal open model. With KDA architecture and ultra-low cost, it rivals GPT-5.6 and Fable 5, redefining AI cost-effectiveness.