AI 代理與開源工具
Headlong Implements a Persistent Agent With an Infinite Bash Loop, Thinking and Acting Even When No One Is Asking
Laude Institute and MIT have open-sourced Headlong, a Bash-based system with fewer than 10,000 lines of code that treats messages as asynchronous observations within a continuous stream of thought rather than as new sessions. The design enables research into long-term memory and autonomous action, but it also turns token costs, permission isolation, and cross-user data boundaries into persistent risks.

Headlong rewrites the conventional agent lifecycle: instead of going dormant after completing an answer, the system uses a Thinker that repeatedly calls `shellm` to generate the next thought. The model can output reasoning text or Bash commands for immediate execution until it sets `FINAL`, after which it schedules its own next wake-up. Messages from Slack, Telegram, and the web are simply injected as observations into the same stream of thought. The agent can delay its response, proactively contact users, or continue existing work without anyone issuing a command.
Its core is intentionally kept to about 9.8K lines of Bash. `traj` stores thoughts and actions as a branchable and mergeable JSONL DAG, while `context` projects the trajectory into the context for the next model call. Recent records are preserved verbatim, while older content is progressively summarized across exponential tiers; the original steps can still be retrieved when needed. Skills, memory, and tools are also represented as files or executable programs, allowing the agent to inspect and even modify its own harness. The team says its test agent has had more than 50 self-authored commits merged into the main branch, but this reflects development experience rather than a capability benchmark.
The tradeoffs are concrete. Model-generated Bash has real side effects. When Docker is available, commands run in a container by default; without Docker, they may run directly with the user's permissions. A single shared stream of thought also provides no inherent isolation of user information, so any member's input should be treated as potentially accessible to other members indirectly. Continuous reasoning uses exponential backoff, but the official configuration still costs about $1 to $2 per hour. Headlong is currently alpha research software, with no quantitative evaluation demonstrating that long-running continuous thought outperforms event-driven or scheduled agents. Key areas to watch include long-horizon task benchmarks, memory-contamination testing, and least-privilege execution strategies.