Prime Agent
An open-source coding and research agent built around a Recursive Language Model that treats context as variables and a persistent Python REPL as its only tool.
Repository Health
Technical Analysis
Prime Agent is an open-source coding and research agent for general-purpose and long-running work, built by Prime Intellect. Instead of exposing a fixed set of built-in tools, it gives the model one persistent Python REPL: file operations, shell commands, tool use, and subagent orchestration all happen as code the model writes and runs itself, with variables and state surviving across turns and context compaction.
The project is organized around two core ideas. The Recursive Language Model (RLM) treats context as variables and subagent calls as ordinary function calls inside that REPL, so a parent model can spawn focused child agents with rlm.spawn(...) and keep its own context lean. The Continual Harness stores supplemental prompts, memories, skill descriptions, and reusable subagent specs as durable state that the agent can refine through small, evidence-backed updates via /refine — without ever rewriting its immutable base system prompt, and with recorded snapshots for rollback.
Beyond the core loop, Prime Agent is built for sessions that outlive a single terminal window: a daemon-backed architecture keeps agents, Python kernel state, schedules, and subagents running when the terminal disconnects, and running agents can message each other directly to coordinate work. Persistent goals, heartbeats, cron-style schedules, and a bounded autonomous mode let it keep making progress on long research or coding tasks across many turns.
The codebase is a TypeScript/Node monorepo (with a Python-facing execution surface) split into an agent runtime, an ai provider layer, a coding-agent CLI/daemon, and a tui terminal interface, backed by an extensive documentation set covering architecture, RPC/JSON automation modes, and the RLM programming model itself.
What You Get
- A persistent Python REPL as the agent’s only built-in tool, with variables, imports, and task handles surviving across turns and compaction
- Programmatic subagents via
rlm.spawn(...)for parallel or background work, returning results directly into the parent’s Python state - A Continual Harness with
/refinethat persists small, evidence-backed lessons as supplemental prompts, memories, or subagent specs, with rollback via recorded snapshots - Daemon-backed sessions that keep running when the terminal disconnects, with reattach,
prime-agent agentsbrowsing, and cross-agent messaging - Persistent goals, heartbeats, and schedules (
/goal,/heartbeat,prime-agent schedule) that re-enter a session over time to keep long tasks moving - A bounded autonomous mode with configurable turn, token, and time budgets plus user-defined quality gates
- An installable skills system where skills are importable Python packages, including a built-in skill creator for turning recurring workflows into reusable skills
- Support for subscription providers (ChatGPT Plus/Pro, Claude Pro/Max, GitHub Copilot, xAI Grok) and API-key providers, plus JSON and RPC modes for headless automation
Common Use Cases
- Running long, multi-hour coding or refactoring sessions that need to survive terminal disconnects and be resumed later
- Automating research workflows where a parent agent spawns multiple focused subagents to investigate different angles in parallel
- Building project- or team-specific skills that codify a recurring workflow as an importable Python package
- Running evaluation harnesses for research (the project name-checks PRIME-RL and Verifiers) that benefit from a scriptable, recursive agent loop
- Scheduling recurring or heartbeat-driven agent work, such as periodic repo checks or progress-tracked long-running goals
- Integrating an agent into existing tooling headlessly via JSON or RPC mode rather than the interactive TUI
Under The Hood
Architecture
Prime Agent separates terminal presentation, process coordination, agent execution, and persisted state into distinct layers: an AgentConnection client boundary talks to a daemon supervisor over a local protocol, which routes work to per-session workers; each worker owns one AgentSessionRuntime with a root AgentSession, a scheduler, a root Python kernel, and any RLM child runtimes spawned beneath it. The AgentSession (a large, central module in packages/coding-agent/src/core/agent-session.ts) owns provider calls, queues, tool execution, compaction, goals, child lifecycles, and transcript persistence, while the Python kernel is treated purely as the model-facing control surface — typed host requests flow back up to TypeScript for anything that touches the real system. This keeps a clear boundary between “what the model can script” and “what the host is authoritative for,” and the same execution path is used whether a prompt originates from a user, a heartbeat, a schedule, a goal continuation, or another agent.
Tech Stack
The project is an npm/TypeScript monorepo (Node >=22.8) split into four workspace packages — agent (the RLM agent loop), ai (a provider abstraction covering OpenAI/Anthropic/Bedrock/xAI/GitHub Copilot and Prime Inference), coding-agent (the CLI, daemon, and core session runtime), and tui (a custom terminal UI layer) — built with the native TypeScript compiler preview (tsgo), linted and formatted with Biome, and distributed via a shell installer plus prebuilt binaries from a dedicated GitHub Actions workflow. A companion Python-facing runtime provides the persistent REPL the agent scripts against.
Code Quality
The repository enforces strict: true TypeScript across all packages via a shared base tsconfig, a Biome-driven check script covering lint, formatting, a custom test-policy checker, an installer check, and a browser smoke check, all gated in CI behind a contributor-trust check. Testing is extensive — several hundred Vitest test files span unit tests, daemon/supervisor lifecycle tests, and numbered regression tests tied to specific historical bugs (e.g. regressions/6006-bundled-bedrock.test.ts), suggesting a project that captures fixed bugs as permanent regression coverage rather than just moving forward.
What Makes It Unique Most coding agents expose the model a curated set of discrete tool calls (read file, run command, spawn subagent) invoked through structured function-calling. Prime Agent instead gives the model exactly one tool — a persistent Python REPL — and reframes every other capability, including recursively spawning and messaging other agents, as ordinary Python the model writes and that state survives across turns and compaction. Combined with a harness that can revise its own supplemental prompts and memories through small, auditable, rollback-able updates (while leaving its base system prompt immutable), this is a genuinely different take on how an agent accumulates working context and operating knowledge over a long-running session, grounded in the team’s own published RLM and Continual Harness research.
Self-Hosting
Licensing Model MIT licensed — all features available with no restrictions or license keys required in self-hosted or local use.
Self-Hosting Restrictions
None found. There are no ee/, enterprise/, or pro/ directories, and no license-check code gating features in the source.
Enterprise Features Not applicable — Prime Agent is a single open-source CLI/TUI agent, not a hosted product with separate paid tiers.
Note on model access Prime Agent itself is fully free and open source, but running it requires a language-model provider: either a subscription (ChatGPT Plus/Pro, Claude Pro/Max, GitHub Copilot, eligible xAI Grok plans) or an API key for a supported provider. That cost is for model access, not for the agent software.
License Key Required No.
Related Apps
OpenClaw
AI Assistants · AI Agents
An open-source AI assistant that runs on your own hardware and meets you in Discord, Slack, WhatsApp, iMessage, Telegram, and 20+ other channels, with native apps for every major platform.
deepseek-harness
AI Agents · AI Development · Developer Tools
An open-source, plugin-based agent harness from DeepSeek AI that runs coding and automation agents across web, desktop, CLI, and SDK surfaces.
OpenCode
AI Code Assistants
A fully open-source AI coding agent built for the terminal, with a TUI, desktop app, web client, plugin system, and SDK — one of the most-starred AI coding agents on GitHub.