What Is the Continual Harness and How Does the /refine Command Improve Session State in Prime Agent?
The Continual Harness is a persistent, lightweight datastore that lives alongside the Recursive Language Model (RLM) kernel to record supplemental prompts, memories, and skills, while the /refine command enables the agent to iteratively improve this session state through evidence-backed updates without modifying the immutable base system prompt.
The PrimeIntellect-ai/prime-agent repository introduces a novel approach to persistent agent memory through the Continual Harness architecture. This system allows Prime Agent to accumulate reusable knowledge across conversation turns and survive agent restarts without bloating the base system prompt. Unlike traditional approaches that modify core instructions, the Continual Harness maintains a separate, mutable datastore that works in conjunction with the RLM kernel.
Understanding the Continual Harness Architecture
Core Components and RLM Integration
The Continual Harness operates as a persistent datastore alongside the Recursive Language Model (RLM) kernel. According to the implementation in prime-agent-runtime/src/rlm/harness.py, it records supplemental prompts, memories, skill definitions, and reusable sub-agent specifications. Each entry represents a small, self-contained piece of knowledge that the agent can manipulate through CRUD operations without touching the immutable base system prompt defined in packages/coding-agent/src/core/prompts/rlm.ts.
Persistent Storage and Concurrency Safety
The harness state is stored on disk as harness_state.json, making it resilient against agent restarts. The implementation includes concurrency safeguards through HarnessState._sync_from_disk(), which reloads the state if another process rewrites the file. This prevents stale snapshots from overwriting the latest changes when concurrent edits occur, such as simultaneous host /refine requests.
How the /refine Command Improves Session State
The Refinement Workflow
The /refine command serves as the agent-exposed mechanism for improving the session's harness state. When invoked via await refine.run() (documented in packages/coding-agent/skills/refine/SKILL.md) or the host /refine command, the model executes a three-stage process:
- Diagnose the failure and determine which harness component (memory, skill, prompt note, or sub-agent spec) requires modification.
- Apply focused updates using CRUD methods on the harness such as
create_memory,update_skill, ordelete_prompt_note. - Record the change as a
RefinementEventto maintain a concise history of "what was changed and why" for future inspection.
Evidence-Backed State Mutations
Unlike prompt rewriting approaches, /refine applies evidence-backed updates to specific harness components. The command does not rewrite the base system prompt; instead, it only mutates supplemental harness entries. This leaves the core agent behavior unchanged while allowing the session to accumulate reusable knowledge. When the global_ flag is used, these refinements persist across agent restarts.
Implementing Harness Operations in Practice
The following examples demonstrate how to interact with the Continual Harness programmatically using the methods defined in prime-agent-runtime/src/rlm/harness.py:
# 1️⃣ Create a memory about a recurring tip
await rlm.harness.create_memory(
title="Git status reminder",
content="Always run `git status` before committing.",
id="git_status_tip"
)
# 2️⃣ Update a skill after discovering a better pattern
await rlm.harness.update_skill(
id="my_skill",
title="Optimized data fetch",
content="Use asyncio.gather for parallel I/O.",
reference={"type": "python", "import": "my_pkg.fetch", "callable": "fetch_all"},
)
# 3️⃣ Record the refinement that led to the update
await rlm.harness.record_refinement(
trigger="observed repeated I/O slowdown",
changes=["updated skill `my_skill` to use asyncio.gather"],
evidence="timing logs from three runs",
outcome="speedup ≈ 2×"
)
# 4️⃣ Inspect the current harness overview
print(await rlm.harness.overview())
Key Implementation Files
According to the Prime Agent source code, the Continual Harness and /refine functionality are implemented across several critical files:
prime-agent-runtime/src/rlm/harness.py: Contains the coreHarnessStateclass, CRUD methods (create_memory,update_skill,delete_prompt_note), andrecord_refinementimplementation.packages/coding-agent/src/core/prompts/rlm.ts: Defines the system prompt snippet that informs the model about the Continual Harness and proper/refineusage.packages/coding-agent/skills/refine/SKILL.md: Provides user-facing documentation for theawait refine.run()skill interface.packages/coding-agent/test/system-prompt.test.ts: Validates that the system prompt correctly contains the Harness state section and refine guidance, ensuring the model understands how to utilize these capabilities.
Summary
- The Continual Harness is a persistent datastore that maintains supplemental knowledge separate from the base system prompt, stored in
harness_state.json. - The
/refinecommand enables iterative improvement of harness state throughawait refine.run(), applying targeted updates to memories, skills, and prompts without modifying core agent behavior. - Concurrency safety is ensured via
HarnessState._sync_from_disk(), preventing data loss during simultaneous access. - Traceability is maintained through
RefinementEventrecords, which document the trigger, changes, evidence, and outcome of each refinement operation. - Changes can persist across agent restarts when using the
global_flag, enabling long-term knowledge accumulation.
Frequently Asked Questions
What is the difference between the Continual Harness and the base system prompt?
The Continual Harness maintains mutable supplemental entries (memories, skills, sub-agent specs) in harness_state.json, while the base system prompt remains immutable. The harness allows dynamic updates through the /refine command without altering the core agent instructions defined in packages/coding-agent/src/core/prompts/rlm.ts.
How does the /refine command prevent data loss during concurrent operations?
The /refine command leverages HarnessState._sync_from_disk() to reload the state from disk before applying changes. If another process (such as a host /refine request) modifies harness_state.json simultaneously, the guard detects the discrepancy and refreshes the local snapshot, preventing stale overwrites.
Can refinements made via /refine persist after the agent restarts?
Yes, when refinements are created with the global_ flag, they persist across agent restarts because the Continual Harness stores all entries in the persistent harness_state.json file on disk, rather than maintaining state only in memory.
What types of components can be modified using the /refine command?
The /refine command can modify four primary harness components: memories (via create_memory), skills (via update_skill), prompt notes (via delete_prompt_note or similar CRUD methods), and sub-agent specifications, all without affecting the immutable base system prompt.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →