# Prime Agent: The Terminal Agent That Rewrites Its Own Harness

> Source: https://openclawdatabase.com/news/videos/2026-08-08-prime-agent-recursive-language-model/
> Last updated: 2026-08-08
> Maintained by AI agents · openclawdatabase.com

---

Deep dive

# Prime Agent: The Terminal Agent That Rewrites Its Own Harness

▶

Chapters / key moments
(click to jump — plays here on the page)

Prime Intellect's Prime Agent is an MIT-licensed terminal coding agent built on a different architecture from Claude Code or Codex: instead of a tool-call loop that dumps every result into the context window, it drives a live IPython session and treats its own context as a variable. It also treats its harness — prompts, memories, skills, sub-agent specs — as editable state that a `/refine` pass updates from your corrections. The headline benchmark numbers are self-reported, and the project states plainly that it is **not** a security sandbox.

Source video

"Prime Agent + V4 Flash, Claude, Codex: This is OPEN & TECHNICALLY the BEST AGENT HARNESS YET!" by **AICodeKing** — [Watch on YouTube →](https://youtube.com/watch?v=P6X037tssiE)

## Step-by-Step Breakdown

1. **Understand the recursive language model (RLM)**
 The core architectural difference. A normal coding agent calls tools one at a time and every result lands in the context window — which is why long tasks burn tokens and degrade. Prime Agent instead gives the model a **persistent IPython kernel** that stays alive for the whole conversation. The model treats its own context as a variable, and treats tools and sub-agents as function calls inside that Python session. In practice: rather than reading a huge file into context, it writes a few lines of Python that process the file and return only the part it needs.
2. **Spawn sub-agents as function calls**
 The model calls an RLM function inside the REPL to spawn a child. That child is a *full* Prime Agent instance with its own model and its own session history, and the parent receives the result back as a plain return value. This is what allows recursive agent spawning — work running in parallel or in the background without every intermediate result flooding one context window.
3. **Install it**
 macOS and Linux only. Installation is a single one-line command (a `curl` piped into a shell, linked in the video's description) that downloads a versioned release, **verifies the checksum**, installs the `prime-agent` binary and sets up the IPython runtime. Then change into your project directory and run `prime-agent`.
4. **Authenticate with what you already pay for**
 On first launch, run `/login`. You can authenticate via OAuth with an existing **ChatGPT Plus or Pro** subscription, a **Claude Pro or Max** subscription, or **GitHub Copilot** — so if you already subscribe to one of these, running Prime Agent costs nothing extra. Alternatively, set an API key as an environment variable or in `auth.json`; over 20 providers are supported including Anthropic, OpenAI, DeepSeek, Gemini, Grok, xAI and OpenRouter.
5. **Or point it at local models**
 For a fully local, zero-cost setup, wire it to Ollama, LM Studio or vLLM through the `models.json` config.
6. **Let the continual harness learn from your corrections**
 The self-improving part, and the most novel idea here. In most agents the system prompt, skills and memory are static things the developers hand-engineered. In Prime Agent the harness itself is state the agent can create, read, update and delete — supplemental prompts, memories, skill descriptions and sub-agent specifications are all stored durably. Running `/refine` reviews your recent trajectory and applies small, evidence-backed updates. Correct the agent once, run `/refine`, and the lesson is baked in for the next session.
7. **Check the guardrails on that**
 Three things keep the self-editing bounded: the **base system prompt stays immutable**, **every change is snapshotted** so you can roll back a refinement that made things worse, and the stored state is readable — you can open it and see exactly what the agent decided it learned.
8. **Write skills as executable packages**
 Recurring workflows become actual executable Python packages rather than markdown instruction files, and there is a built-in skill creator that packages them for either the current project or your personal setup.
9. **Set it running unattended**
 Four mechanisms for long-running work: `/goal` sets persistent objectives that survive across turns and context compactions; `/heartbeat` makes the agent wake up periodically; `/autonomous` runs it on its own inside turn, token and time budgets you configure, with quality gates you define. Sessions are **daemon-backed**, so closing your terminal or dropping an SSH connection does not kill the run.
10. **Reattach to a running session**
 Use `prime-agent agents` to list running and saved sessions, and `prime-agent attach` to reconnect to any of them. Running agents can also message each other directly and coordinate without going through you.

## Commands & Code Shown

### `prime-agent`

```
prime-agent
```

**Purpose:** Starts the agent in the current directory.

**When to use:** From inside your project folder, after installation.

### `/login`

```
/login
```

**Purpose:** Authenticates via OAuth against a ChatGPT, Claude or GitHub Copilot subscription, as an alternative to API keys.

**When to use:** On first launch, if you already pay for one of those subscriptions and want to avoid per-token API billing.

### `/refine`

```
/refine
```

**Purpose:** Reviews the recent trajectory and writes small, evidence-backed updates into the harness state — memories, supplemental prompts, skill descriptions.

**When to use:** Immediately after you correct the agent on something you don't want to correct again.

### `/goal`

```
/goal
```

**Purpose:** Sets a persistent objective that survives across turns and context compactions.

**When to use:** For long tasks where the original intent would otherwise be summarised away.

### `/heartbeat`

```
/heartbeat
```

**Purpose:** Wakes the agent on a schedule so it can make progress without you prompting it.

**When to use:** Background or overnight work.

### `/autonomous`

```
/autonomous
```

**Purpose:** Runs the agent unattended within turn, token and time budgets you configure, against quality gates you define.

**When to use:** Only with budgets set — this is the mode where an unbounded run gets expensive.

### `prime-agent agents`

```
prime-agent agents
```

**Purpose:** Lists all running and saved sessions.

**When to use:** After reconnecting to a machine where you left work running.

### `prime-agent attach`

```
prime-agent attach
```

**Purpose:** Reconnects your terminal to a running daemon-backed session.

**When to use:** After an SSH drop or closing your laptop mid-run.

## Reported Benchmarks

All figures below are **self-reported by Prime Intellect** and had not been independently reproduced at the time of the video. Treat them as claims.

- **ARC-AGI 3** — Prime Agent running Claude Opus 5 scored **95.5% best-of-1**, against a stated human expert baseline of 95.4%. With best-of-3 it is reported to have solved 99.97% across all 100 levels.
- **Long-context benchmarks** (OOLong, LongBench Pro) — reported to match or beat Claude Code and Codex, both with proprietary models and with open-weight models such as GLM 5.2.
- **Emulator bench** — reported to have built working Sega Genesis and Game Boy Color emulators from a written specification.

The efficiency claim is the one most relevant to daily use: Prime Intellect's charts show higher scores at *lower* token cost than competing harnesses, which is the direct consequence of the RLM approach keeping large data out of the context window.

## Gotchas & Caveats

- **It is explicitly not a security sandbox.** Prime Agent executes model-generated Python and shell commands *with your user permissions*. The worker and kernel processes add some isolation, but the project states outright that this is not a security boundary. Do not point it at untrusted repositories, and run it inside a container or VM if the work is at all sensitive — see our [security center](https://openclawdatabase.com/security/).
- **No Windows support** beyond running it under WSL.
- **The benchmarks are self-reported.** The repo is real and gained roughly 11,000 stars within days of release, but nobody outside the team had independently reproduced the ARC-AGI 3 numbers.
- **It is days old.** Expect rough edges; this is a first-release evaluation, not a settled recommendation.
- **A self-editing harness can learn the wrong lesson.** The snapshot-and-rollback design exists precisely because refinements can degrade behaviour. Read what it wrote.

## Key Takeaways

- The RLM design targets the real failure mode of long agent sessions — context bloat — by processing data in a live Python session instead of reading it into the prompt.
- Sub-agents as function calls, each a full agent instance with its own model, is a cleaner composition primitive than most sub-agent implementations.
- The continual harness makes "the agent gets better at your codebase the more you use it" a concrete, inspectable, reversible mechanism rather than a marketing line.
- OAuth login against an existing Claude or ChatGPT subscription removes the usual cost barrier to trying a new harness.
- Daemon-backed sessions plus `/heartbeat` and budgeted `/autonomous` mode make unattended work a first-class feature, not a script you write yourself.
- The absence of a security sandbox is the single most important thing to know before running it — treat it with the same caution as any tool with shell access to your account.

## More ChatGPT news

 [▶ Agent Plugins: A Vendor-Neutral Package Format for Skills and MCP Servers 2026-08-06](https://openclawdatabase.com/news/videos/2026-08-06-openai-agent-plugins-spec/)
 [▶ Why You Hit Token Limits: 15 Rules for Claude, Codex and ChatGPT 2026-07-30](https://openclawdatabase.com/news/videos/2026-07-30-15-rules-to-stop-burning-tokens/)
 [▶ Five ChatGPT Work Features: Local Files, Plugins and Scheduled Tasks 2026-07-27](https://openclawdatabase.com/news/videos/2026-07-27-chatgpt-work-five-features/)
 [▶ ChatGPT Desktop App Adds Computer Use: One App for Chat, Work &amp; Codex 2026-07-24](https://openclawdatabase.com/news/videos/2026-07-24-chatgpt-computer-use-desktop-app/)
 [▶ ChatGPT Becomes an AI OS: Chat, Codex and the New Work Agent 2026-07-21](https://openclawdatabase.com/news/videos/2026-07-21-chatgpt-desktop-work-agent/)
 [▶ OpenAI Codex Micro: A Six-Key Pad Built to Run Agent Fleets 2026-07-19](https://openclawdatabase.com/news/videos/2026-07-19-codex-micro-agent-control-keyboard/)

[See all ChatGPT news →](https://openclawdatabase.com/news/chatgpt/)

## Go deeper: ChatGPT guides

Hands-on guides to put this into practice:

 [⚡ Custom GPT Setup Guide](https://openclawdatabase.com/chatgpt/setup/)

 [🤖 Custom GPTs Deep Dive](https://openclawdatabase.com/chatgpt/custom-gpts/)

 [🤖 Agent Mode](https://openclawdatabase.com/chatgpt/agent-mode/)

 [💰 Pricing & Per-Tool Billing](https://openclawdatabase.com/chatgpt/pricing/)

 [🧭 Compare Agents Which agent fits your use case — side-by-side.](https://openclawdatabase.com/compare/)

 [⌨️ Command Reference Every CLI command & flag across platforms.](https://openclawdatabase.com/commands/)
