# Prime Agent Runs the Whole Session Inside a Python REPL

> An open-source coding agent that runs the session as a persistent IPython REPL, with a self-editing harness that never touches the base system prompt.

Published: 2026-08-14
URL: https://daniliants.com/insights/prime-agent-runs-the-whole-session-inside-a-python-repl/
Tags: coding-agents, autonomous-agents, subagents, agent-architecture

---

## Summary

Prime Agent is an open-source coding and research agent that treats an entire session as a persistent Python (IPython) REPL rather than a chat loop. Context, tools, and subagents are all manipulated as code, an approach it calls "prompt-as-a-variable". It layers a self-editing "Continual Harness" on top: durable state (memories, skill descriptions, subagent specs) that a `/refine` command can incrementally update based on evidence from the current trajectory, without ever touching the immutable base system prompt.

## Key Insight

- Core architecture bet: instead of the usual tool-call JSON loop, the agent runs inside a persistent IPython kernel. File ops, shell, subagent spawning (`rlm(...)`), and context management are just Python calls the model writes.
- Skills are literally importable Python packages, not markdown prompt files, and there is a built-in skill creator that promotes recurring workflows into project- or user-level skills.
- Self-improvement is scoped and reversible: `/refine` only appends small, evidence-backed updates to supplemental state (memories, skill descriptions, subagent specs). The base system prompt is immutable, and every refinement is snapshotted for rollback.
- Sessions are daemon-backed, not tied to the terminal. `prime-agent attach <agent>` reattaches to a running session, and agents can run in the background indefinitely with heartbeats and schedules to re-enter periodically.
- Agents can talk to each other directly (`rlm` subagents plus running sessions) without the user relaying messages, making agent-to-agent orchestration a first-class feature.
- "Bounded autonomous mode" (`/autonomous`) runs within configured turn, token, and time budgets plus user-defined quality gates, but the docs are explicit that a passed gate only verifies what it checks, not overall task success.
- Explicit non-sandbox warning: it executes model-generated Python and shell commands with the user's real permissions. Worker and kernel isolation improves recovery, not security. The recommendation is to run in a disposable clone, worktree, or checkpoint rather than directly on a trusted repo.
- Built on top of `pi` (earendil-works/pi), alongside PrimeIntellect's own `verifiers` and `prime-rl` projects, so it is part of a broader RL and agent-training ecosystem rather than a standalone toy.