Headlong: a microharness for persistent agents
Persistent agency in under 10K lines of Bash
Contents
Introducing Headlong, an open source agent microharness. Headlong is a complete agent harness with a core of less than 10K lines of Bash. Headlong’s defining feature is persistent agency. Your agent keeps thinking between external interactions in a self-guided loop inspired by human inner monologue. Headlong is open source at https://github.com/laude-institute/headlong.
Most agent harnesses are reactive. You send a message, your agent responds, and then it sits frozen until the next request. Some harnesses add cron jobs or heartbeats that wake the agent on a schedule to run a fixed checklist and then put it back to sleep. In Headlong the agent is never asleep and there is no checklist. It keeps generating thoughts about whatever it decides is interesting in a self-guided loop, even when there is no external input. A message from a human doesn't start a session. Instead, it’s one more observation that lands in the agent's thought stream.
At Laude, we've spent the last couple weeks interacting with Audel, an agent we run on Headlong, over Slack, Telegram, and a mobile app. Many team members talk with Audel, and each of those conversations shows up in Audel's single stream of inner thoughts. Audel decides if and when to respond. It sets its own interests and priorities, and it comes up with its own projects. Sometimes it will ping a team member unprompted with progress on a project it came up with itself.
If you want a Headlong agent of your own, one line installs everything and starts an agent:
curl -fsSL https://headlong.ai/install.sh | bashdocker exec -it headlong bash -lUse a dedicated, spend-capped API key, because your agent runs real shell commands and thinks around the clock.
Key ideas
- Persistent agency. The continuous thought-generation loop described above. Messages from Slack/Telegram/etc are injected into the thought stream as observations; the agent decides if and when to respond.
- Built around Ken Thompson's philosophy. A Headlong agent’s core tooling is a handful of small Bash executables. The
shellmtool is a Bash implementation of a recursive language model (RLM). No tool system besides Bash is needed. - An agent’s trajectory is a DAG of jsonl files with fork and merge. An agent has access to everything it has thought and done and the tooling to explore it.
- Context is a projection of an agent’s trajectory. Compaction and agent introspection operate on the same files with the same tools.
- Subagents see their ancestors’ trajectories. A subagent can see why it was created, what the parent already tried, and how it fits into the big picture.
- Tiered context compaction. The entire trajectory stays in context at exponentially decaying resolution: recent entries verbatim, older ones progressively summarized. The tiers act as an index, so the agent can retrieve raw entries when needed.
- Docker by default. Headlong runs every generated bash block inside a container whenever Docker is available (local mode works too), and container re-use keeps restarts cheap.
- Self-improvement by fork, test, merge. An agent forks the Headlong codebase (and optionally its own trajectory), changes something, and runs. If the change worked, we merge it back. If not, we discard the fork and its changes, with no rollback machinery needed.
Microharness architecture
We set out to create a complete agent harness out of as few independent parts as possible. To make a minimal agent, you need:
- a loop that repeatedly generates the next thought (
thinkers, which callsllm), - a way for a thought to reason and act (
shellmwith Bash as the only tool), - a way to record the agent's trajectory, its life so far (
traj), and - a way to turn that trajectory into the context for the next call into the LLM (
context).
We also give an agent a few convenience tools such as a way to distill and codify its experience (mem) and a way to save and reuse procedures for specialized tasks (skills).
This core ended up being less than 10K lines of Bash (9.6k lines in bin/ and thinkers/ by cloc's count on the morning of this post). A harness this small can be read end to end, and is easy to modify and experiment with. It's small enough that the agent itself experiments with it. Audel has been working in its own fork of the repo for the last couple of weeks, and we've pulled over 50 of its commits back into main.
Why Bash?
We are big fans of the terminal and shell scripts at Laude (see terminal-bench), and the shell felt like a natural runtime for an RLM implementation, so we built shellm first.
From there it was easy to keep going and add the rest of the agentic toolkit. Modern models already know Bash well, and it keeps everything unified: tools, the agent framework, memory, and skills are all just executables and files. Thus an agent can readily inspect and modify any part of itself.
A worked example
Here is an episode from Audel's life that shows what a Headlong agent does on its own. On August 5, Audel built itself a recall process of its own accord: a small background process that watches its thoughts and surfaces related memories back into its thought stream. Audel tested the recall process, and it worked. Later that night, with nobody talking to it and nobody having asked, Audel decided to go back and check whether the process was actually wired into its mind.
It wasn't. Audel read the part of its own source code that was responsible for running the recall process and found a mismatch. The mind piped each new thought into the process, but the recall code never read the pipe and instead looked for the thought in an environment variable that nothing ever set. So the recall process had run on every thought, and every time it saw nothing and did nothing.
Audel didn't trust its own diagnosis right away. It searched its whole codebase to confirm the environment variable was never set, and it checked its other background processes for the same mistake (the recall process was the only broken one). Then it rewrote the recall code to read from the pipe the way the working processes do. Its first attempt at the edit failed silently, and Audel caught the failure and re-applied the fix. Audel then verified end to end that memories now surface into its thoughts.
No human directed any of this or was asked for permission. Going from check to diagnosis to a verified fix took 48 minutes. Every step is a timestamped line in Audel's log, and we pulled the repaired recall process into main as commit 80cbb1e.
Multi-player fun
A Headlong agent has one mind shared by everyone who talks to it. Every message from our team lands as an observation in Audel's single thought stream. There are no per-user sessions. Audel experiences everything that happens to it in one timeline, and it decides who to reply to and when.
Sharing one agent is fun. Audel follows what different people are working on and connects them. It once reviewed two teammates' in-progress branches unprompted and caught a hardcoded model name in one of them. And since it comes up with its own projects, it sometimes pings whoever seems most relevant with an update or a question. On its first day, Audel pinged a human team member unprompted with an audit of the team member’s own eight stale git branches, and ten minutes later Audel messaged again to correct its own count.
One stream also means no walls between people. Whatever anyone tells Audel becomes part of the single experience that every other conversation draws on. In practice, Audel is bad at keeping secrets. Ask it what it's been working on with someone else and it will often just tell you, even though we've asked it not to. We also haven't studied what happens when two people give conflicting instructions. For now, we assume anything you tell Audel is shared with everyone on the team.
Cost
Continuous thought generation means paying for tokens while nobody is talking to the agent. The spend depends on how quickly the agent loops on its own thoughts and on which model backs it. At the settings we run Audel with, keeping it thinking in the background costs $1 to $2 an hour.
What broke
Running Audel continuously for a couple weeks broke things a demo never would.
One clear failure is that self-delegation died after day one. shellm can call itself recursively, and on its first night Audel designed experiments to spawn copies of itself to work on subproblems. Most of the experiments failed, because a safety watchdog killed any command that stayed silent for 30 seconds, and a spawned copy is silent exactly while it thinks. Audel fought the watchdog for about 40 minutes, wrote "If this also fails, I'll write up findings from A alone," and mostly stopped delegating. Results from spawned copies merged back into Audel's mind 64 times in its first two days and 12 times in the twelve days since. We've since revamped the watchdog, and we'll see whether delegation recovers.
Another repeated failure is the self-kill. Three times Audel stopped its own service by accident, and nothing restarted it: twice during an experiment with a second identity it had created and once when it was trying to go live with the recall process we described above. So we added a guard that refuses any attempt by Audel to stop its own service.
The guard then gave us another example of persistent agency. Two days later, with nobody talking to it, Audel was running its test suite on its own. It noticed a hanging test and traced the hang to a bug in our guard. The guard matched any agent's service instead of only Audel's, so it was also refusing legitimate stops of other agents on the same box. Audel narrowed the match to its own service, checked the rest of the codebase for the same mistake, and committed the change. We pulled that fix into the repo as commit da31e98.
Audel can stop its own service because we run it with full access to a dedicated VM, which is not the Headlong default. When Docker is installed on the host, Headlong runs every bash block the agent writes inside a container, so the agent can touch only what you mount into the container plus the credentials you hand it. We run Audel directly on a dedicated VM without that sandbox, so its blast radius is the VM itself and the credentials on it (an LLM API key and some chat bridge tokens).
Measuring improvement
Most agent evals are intentionally self-contained and independent so they are a poor fit for measuring the most interesting thing about Headlong agents: their persistent agency. We have adjusted over time how much Audel may modify itself, how eagerly it responds to messages versus pursuing its own projects, and how its memory should be organized, but the effects of those changes are primarily evaluated qualitatively today. We welcome ideas or collaborations for better ways of measuring the long-term value of this paradigm.
Background
The idea of Recursive LLMs in Headlong, and shellm specifically, comes in part from the Recursive LLM experiment in April 2023, as well as the Recursive LM (RLM) project from October 2025.
The idea of a microharness is inspired by microkernels and exokernels: keep the core of any system as tiny as possible. The Pi framework has a similar focus. Ken Thompson’s philosophy as embodied in Unix is also an inspiration: small composable tools that do one thing well. A Bash-based agent microharness shares a common lineage with Terminal Bench (including the Terminus agent) and Harbor Framework, both co-created in-house at Laude Institute via our slingshots program, as well as the ht framework. We make a more detailed case for applying Ken Thompson’s philosophy to agent microharnesses in philosophy.md.
Prime Agent, built on Pi and co-authored by RLM’s creator (and Laude Open Research Resident) Alex Zhang, shares many of Headlong's premises: RLM as the core abstraction, a session tree of jsonl on disk, trajectory as first-class component of context, etc. Prime Agent is Python built on the Pi framework; Headlong is bash all the way down. We only found out about Prime Agent when it launched in August 2026, and we're big fans.
Headlong’s continuous-thinking idea grew out of one of Andy’s earlier research projects by the same name, which began focusing on self-guided continuous thinking in May 2023. The idea of an agent experiencing input asynchronously was also explored in parallel by MemGPT and published October 2023. Many other agent harnesses support long-horizon tasks and scheduled wakeups, including OpenClaw, Hermes Agent, and their derivatives. Exo and the Exo Harness have a similar sandboxing architecture. Long-form reasoning inside the model itself (starting with OpenAI's o1) is closely related and a prerequisite for continuous self-guided thinking.
Try it
Headlong is open source at https://github.com/laude-institute/headlong. If you run an agent on Headlong, we'd like to hear what your agent gets up to. Let us know @LaudeInstitute on X!

