Prime Bun: A Bun-Native RLM Agent
Documentation • Verifiers • PRIME-RL • pi-mono
Bun-native by design
Prime Bun replaces the Python notebook with a native Bun implementation. RLM programs execute as persistent JavaScript or TypeScript directly in Bun—not through a Python wrapper or subprocess bridge—with retained session state, prepared runtime globals, native shell execution, abort and recovery handling, and snapshot support.
Lower is better. These are end-to-end host/kernel timings for Prime Bun v0.7.4 on Bun 1.4.0 versus the official Prime Agent v0.8.0 release on Python 3.11.15.
| Operation | Prime Bun | Prime Agent | Prime Bun delta |
|---|---|---|---|
| Cold kernel startup | 44.88 ms | 273.38 ms | 83.6% faster |
| Scalar cell | 0.81 ms | 2.51 ms | 67.8% faster |
| 64 KiB output | 0.96 ms | 2.64 ms | 63.7% faster |
| 10,000 one-byte writes | 1.17 ms | 14.57 ms | 92.0% faster |
| Shell command | 3.39 ms | 8.78 ms | 61.3% faster |
| Abort synchronous loop | 113.13 ms | 76.32 ms | 48.2% slower |
| First cell after recovery | 2.93 ms | 2.78 ms | 5.3% slower |
| 32 MiB snapshot | 12.81 ms | 16.78 ms | 23.6% faster |
| 2,000-cell loop, per cell | 0.78 ms | 2.71 ms | 71.2% faster |
Measured on an Apple M1 Pro running macOS 26.4.1. Each value is the median result across three matched rounds; each round used 12 cold startups, 40 ordinary-operation samples, six abort/recovery and snapshot samples, and 2,000 scalar cells. One-time runtime installation and bootstrap were excluded.
Note
Prime Bun is a fork of Prime Agent. All credit for the original agent, RLM architecture, TUI, and surrounding ecosystem goes to Prime Intellect and the Prime Agent contributors. Their thoughtful and ambitious work created an exceptional open-source foundation; this fork focuses on a Bun-native JavaScript and TypeScript runtime.
Prime Bun builds on Prime Agent, an open-source coding and research agent for general and long-running work. It preserves two core abstractions:
- The Recursive Language Model (RLM) treats context as variables (prompt-as-a-variable) and tools like recursive subagents as function calls (programmatic tool /sub-agent calling) inside a persistent REPL.
- The Continual Harness stores supplemental prompts, memories, skill descriptions, and reusable subagent specifications as durable state that Prime Bun can refine through small, evidence-backed updates, local to the session by default.
Prime Bun combines a persistent Bun JavaScript control environment with durable harness state, so useful working context and reusable operating patterns can outlive a single chat window.
- Everything is programmatic: the persistent Bun notebook is the built-in model tool; file operations, shell commands, skill use, subagents, and context management happen through JavaScript or TypeScript.
- Subagents are built in:
rlm(...)spawns real child agents for parallel or background work and returns an admission handle; results arrive through explicit agent messages or files. - The harness can improve:
/refinereviews the current trajectory and can apply small, evidence-backed updates to supplemental harness state. It never rewrites the immutable base system prompt, and recorded snapshots support rollback. - Skills are executable: JavaScript-backed skills load prepared globals into the notebook, and the built-in skill creator can turn recurring workflows into project or personal skills.
- Sessions run in the background: daemon-backed agents keep running when the terminal disconnects and can be reattached later.
- Agents communicate directly: running agents can exchange messages and orchestrate one another without routing everything through the user.
- Long tasks keep moving: automatic compaction, persistent goals, heartbeats, schedules, autonomous mode, and retained subagents preserve progress across turns and terminal sessions.
Getting Started
Install the local checkout with Node.js 22.8 or newer:
git clone https://github.com/sng-asyncfunc/prime-bun.git
cd prime-bun
npm ci
npm linkPrime Bun requires Bun 1.4.0 or newer for its persistent JavaScript runtime. The first install can prepare the official Bun runtime automatically when needed.
npm link exposes the checkout as the prime-bun command. Run it from the repository or directory you want Prime Bun to work in:
cd /path/to/project
prime-bunOn first launch, run /login to choose a subscription or API-key provider. Prime Bun works in the current directory and can run commands and modify files there. Use a disposable clone, clean worktree, or another checkpoint you can inspect and restore.
Warning
Prime Bun executes model-generated JavaScript, TypeScript, and project commands with your user permissions. Its worker and notebook processes improve lifecycle isolation and recovery; they are not a security sandbox. Review changes and use trusted repositories, instructions, skills, and extensions only. Run untrusted code or instructions in an external sandbox or restricted environment.
Useful commands:
prime-bun agents # Browse running, idle, and saved sessions prime-bun attach <agent> # Reattach to a running session prime-bun --resume <path|id> # Resume a saved session prime-bun status # Inspect background service state prime-bun doctor [--fix] # Inspect or repair background services prime-bun shutdown [--force] # Stop every agent, worker, and background service
Built for Long-Running Work
Prime Bun is built for long-running work, especially for evaluations in research. These features are available in the TUI and when run autonomously.
- Continual Harness:
/refinecan persist focused, reviewable lessons as supplemental prompts, memories, reusable skill descriptions, or subagent specifications, with recorded refinement history. It does not replace packaging and reviewing new executable skills. - Direct agent-to-agent communication: running agents and retained subagents can discover one another, exchange messages, and steer active work.
- Daemon-backed continuity: active sessions, Bun notebook state, schedules, and subagents keep running when the terminal detaches and can be reattached later.
- Heartbeats and schedules:
/heartbeat,rlmHeartbeat, andprime-bun schedulecan re-enter a session periodically or at a specific time. - Persistent goals:
/goalkeeps an objective and its progress active across turns until it is completed, paused, or cleared. - Bounded autonomous mode:
/autonomouscontinues within configured turn, token, and time budgets and can run user-defined quality gates. A passed gate checks only what that gate verifies; reaching a limit does not imply task success.
Documentation
- Quickstart — install, authenticate, and run a first session
- Usage and CLI reference — commands, sessions, autonomous limits, and output modes
- Long-running and background agents — detach and reattach, goals, heartbeats, and schedules
- RLM programming model — persistent Bun execution, subagents, skills, and the trust model
- JSON mode and RPC mode — headless automation and integrations
- Skills — install and create reusable capabilities
- Provider setup — subscription and API-key providers
- Architecture overview — daemon, worker, notebook, and persistence boundaries
- Development — build and run from source
Acknowledgements
Our agent and TUI is built on top of pi. We thank the authors of pi for their valuable work.
License
Prime Bun is fully open source and released under the MIT License.
Disclaimer
I am not claiming JavaScript wins every RLM race. If you are building data pipelines, running heavy numerical analysis, or using the classic scientific stack, Prime Agent's native IPython setup is exactly what you need.
But the future of coding agents isn't strictly data science. It is web infrastructure, edge deployments, and massive TypeScript monorepos. Prime Agent is an incredible leap forward for autonomous coding. But if you are building for the web, do yourself a favor: kill the Python kernel and run it in Bun.
