LLM + RoboticsModule 10 · Agents & harnesses

Self-improving agent harnesses: Recursive Language Models, Continual Harness and Prime Agent

Instead of stuffing everything into the model's context, let the model hold its context in variables, write code over it, call copies of itself, and edit its own notes, skills and helpers as it learns.

Source: Yacine Mahdid, X post (23 Oct 2026), announcing a 2h36m walkthrough with Seth Karten (Prime Intellect): “Prime Agent: Self-Improving RLM Harness”. I couldn't watch the video, so this module is built from the primary written sources: the Prime Agent paper, repo and launch post, the RLM paper and posts, and the Continual Harness paper. All are saved in sources/10-*.

Start here (no maths needed)

A "harness" is everything wrapped around an AI model so it can do long jobs. The new idea: let the model organise its own notes and helpers, and improve them as it goes.

Think of it like this

Imagine doing a huge school project. You can't hold every page of every book in your head at once. So you keep a binder with labelled tabs, you ask friends to read some chapters and report back, and you keep a "tips that worked" sheet that you update after every mistake. Smart students don't just read harder. They get better at organising.

How it works

  1. The AI gets a notebook it can run code in. Big inputs (whole books, codebases, logs) sit in the notebook as named variables, not in its "head".
  2. It writes small programs to search, cut up and filter that material.
  3. For big jobs, it sends pieces to helper copies of itself, which work in parallel and message back.
  4. After a while, it looks back at what happened and makes a small, careful change to its notes, skills or helpers, and can undo it if it was a bad idea.
  5. It keeps going (bounded by limits on time, tokens and turns) until a check says the job is done.

Why robots care

The "tips sheet that improves itself" idea was first built for an AI playing Pokémon. That's a game where you can't restart, can only see part of the world, and must plan for a very long time, just like a real robot. Robots can't press "reset" in your kitchen, so learning while doing, without restarts, matters a lot.

Try it

Words to know

Harness
The software around an AI model: tools, memory, instructions and helpers.
Context window
How much text the model can "see" at once.
REPL
A notebook where you type code, run it, and see results straight away.
Sub-agent
A helper copy of the AI given part of the job.
Context rot
Models getting worse as their context fills up with lots of text.

Going deeper: everything below is the full version. On a first read, look at the three-ideas table, the demo and the robotics section.

Track: LLM + Robotics. RLMs and Prime Agent are LLM agent technology. Continual Harness, one of Prime Agent's two pillars, was designed for embodied agents with long horizons and partial observability, so it connects directly to robot autonomy.

In this module
  1. Summary
  2. Why this matters for robotics
  3. Deep dive: Recursive Language Models (interactive)
  4. Deep dive: Continual Harness, an agent that edits its own harness
  5. Deep dive: Prime Agent, putting it together
  6. Deep dive: results, and how to read them
  7. Deep dive: safety and bounds
  8. Playbook
  9. Self-check
  10. Glossary & further reading

1. Summary

TL;DR

Prime Agent (Prime Intellect with collaborators, Aug 2026) is an open-source (MIT) coding and research agent built on two ideas:

The design philosophy: the harness standardises execution, recovery, verification and accounting, but leaves strategy to the model, so harness failures don't masquerade as model failures.

IdeaProblem it attacksCore mechanismSource
RLMContext rot and context-window limitsContext stored in a REPL variable; the model programmatically examines and decomposes it and recursively calls itself on snippetsZhang, Kraska & Khattab, arXiv 2512.24601 (blog Oct 2025; paper Dec 2025, revised May 2026)
Continual HarnessHand-engineered prompts, skills and memory that never adapt; prompt optimisation that needs episode resetsHarness state H = (ρ, G, K, M), meaning prompt, sub-agents, skills and memory, refined online within a single runKarten et al., arXiv 2605.09998 (May 2026)
Prime AgentHarnesses built around older models' limits (fixed tool schemas, compaction)RLM REPL + Continual Harness + persistent sub-agents + agent-to-agent messaging + a background daemonKarten, Zhang et al., arXiv 2608.23552 (Aug 2026); repo

2. Why this matters for robotics

3. Deep dive: Recursive Language Models

The problem. Per-token cost rises with context length, and quality tends to fall as contexts grow. This is called context rot. Common fixes: summarise or compact the history (lossy), or pass state between agents through files.

The RLM move. Don't give the model the context at all. Give it the query, plus a REPL in which the context is pre-loaded as a variable. The model (the "root" LM, depth 0) writes code to peek at, search, slice and transform that variable. It can also call sub-LMs, fresh copies of itself, on pieces of it, and combine their answers. From the outside it's a drop-in replacement for a normal completion call.

# the shape of an RLM call (illustrative, not the library's exact API)
answer = rlm.completion(query, context=huge_text)   # same interface as an LM call

# inside, the root model might write:
chunks  = split(context, 100_000)
notes   = llm_batch([f"Find mentions of X in:\n{c}" for c in chunks])   # parallel sub-LMs
answer  = llm(f"Combine these findings to answer: {query}\n{notes}")

Reported results (RLM paper abstract):

Interactive: what a recursive call tree costs

Exact arithmetic for a simple split-and-delegate strategy. Each level splits its input into pieces that fit the sub-call window, and each parent reads only short notes from its children. No accuracy is modelled here; this shows structure and token cost only.

Levels of helpers
–
Sub-calls
–
Tokens the root reads
–
Total tokens read
–

Notice that the root's reading stays small however big the context gets, while the total work grows only slightly faster than the context itself (leaves read everything once; parents read notes). Real RLMs are smarter: they filter with code first and skip irrelevant chunks entirely.

4. Deep dive: Continual Harness, an agent that edits its own harness

The observation. In the Gemini Plays Pokémon runs, people kept improving the harness. In the hardest stages, the agent itself began iterating on its strategy through long-context memory. Continual Harness formalises and automates that loop.

The formalism. The harness state is

H = (ρ, G, K, M)   # prompt, sub-agents, skills, memory

Starting from only a minimal environment interface, the agent alternates between acting and refining H, drawing on any past trajectory data, all without resetting the environment.

In Prime Agent, the harness state lives in the REPL as rlm.harness, with one create/read/update/delete surface for all four kinds (prompt notes, memories, skills, sub-agent specs), persisted to disk.

/refine reads the trajectory and applies the smallest relevant edit, recording its trigger and outcome. The planning runs in the background, and the apply step blocks only briefly at a turn boundary. The base system prompt is immutable, and refinements can be rolled back by ID.

Why "small, evidence-backed, reversible" matters: self-modifying systems can drift, the same failure as reward hacking in Module 07. Small diffs, recorded evidence, a fixed core and rollback are the harness-level equivalent of a KL leash.

5. Deep dive: Prime Agent, putting it together

ComponentWhat it does
Persistent IPython kernelThe model's only tool. Files, shell, tools, skills and sub-agents are all called as functions from code.
rlm(...) sub-agentsAsync: spawning returns a handle immediately. Each child is a full Prime Agent session (own model, kernel, history). Results arrive as messages, and children can be steered mid-flight or kept as persistent sub-agents.
Agent-to-agent messagingThrough a background daemon. Limited to the "nuclear family" (parent, sibling, child) to avoid unwanted cross-talk between independent sessions.
Daemon + Agents ViewSessions keep running when the terminal detaches. Crashed workers recover from the session's append-only JSONL plus a kernel snapshot. Idle sub-agents unload after 30 minutes and reload on demand.
Session & contextThe full history is append-only JSONL. Compaction cleans the active context, but the full history stays reachable from the kernel. A spawned agent "garbage-collects" REPL memory.
SkillsImportable Python packages. A built-in skill creator turns recurring workflows into skills.
Autonomous modeGoal + heartbeats + continuation, bounded by max turns, tokens and time, with a quality-gate command that must pass before finishing.

Compare the two ways of beating long context in this course. Module 05 changes the architecture (Kimi K3's fixed-size linear-attention memory). RLMs change the scaffolding, so the model manages context with code. They're complementary. External, addressable memory also echoes the Neural Turing Machine (Module 06, Day 17), now with Python as the memory controller.

6. Deep dive: results, and how to read them

Reading these critically (Module 01 and Module 08 Stage 10 habits):

7. Deep dive: safety and bounds

8. Playbook

  1. Try the minimal RLM first: rlm-minimal. Put a long document in a REPL variable and let a model answer questions by writing code over it.
  2. Compare against "paste it all in" and "summarise then answer" on the same questions. Measure accuracy and total tokens.
  3. Run Prime Agent in a disposable worktree. Give it a goal, a quality gate (tests) and tight turn, token and time budgets.
  4. Watch /refine: read each proposed edit, keep the good ones, and roll back the rest. Treat harness state like code under review.
  5. Robotics exercise: log a simulated robot run (states, events, failures) to a file, load it as a variable, and have an RLM-style agent answer "why did grasp attempt 7 fail?" by querying the log with code.

9. Self-check

What's the key difference between an RLM and summarisation-based compaction?

Compaction replaces history with a lossy summary. An RLM keeps the full context available as a variable and lets the model choose what to read or delegate. Nothing is thrown away by default.

Why does Prime Intellect's RLM give tools only to sub-LLMs?

Tools often produce many tokens. Pushing tool use to sub-LLMs keeps the root model's context lean, and the root sees only the condensed results.

What does "reset-free" mean in Continual Harness, and why does it matter for robots?

The agent refines its prompts, skills, memory and sub-agents online within a single run, without restarting the environment. Real robots can't reset the world between attempts.

Name three safeguards on Prime Agent's self-improvement.

Small, evidence-backed edits with recorded triggers and outcomes; an immutable base system prompt; and rollback of refinements by ID.

Why should benchmark results be read as "model + harness"?

The harness shapes what the model can do: tools, context handling, budgets, gates. Different harnesses give the same model very different scores, which is the paper's own central claim.

How do Module 05's linear attention and an RLM both address long context?

Linear attention changes the architecture so memory stays fixed-size. An RLM changes the scaffolding so the model manages context with code and sub-calls. They're complementary approaches.

10. Glossary & further reading

TermMeaning
Harness / scaffoldSoftware around a model: tools, memory, prompts, control loop
RLMRecursive Language Model: the model manages context as REPL variables and recursively calls sub-LMs
Prompt-as-a-variableContext held in program memory, not in the model's context window
Programmatic tool callingCalling tools and sub-agents as functions from code, not via fixed schemas
Continual HarnessA reset-free method where the agent refines its own prompt, sub-agents, skills and memory
/refinePrime Agent's step that makes small, evidence-backed harness edits
Context rotQuality decline as context grows
Context foldingMethods that manage the context window during a long rollout (branch/return, hierarchical summaries)
Quality gateA command (e.g. tests) that must pass before an autonomous run may finish