Loki Mode: RARV Cycle & Memory
Relevant source files
The following files were used as context for generating this wiki page:
- bundled-skills/loki-mode/references/core-workflow.md
- bundled-skills/loki-mode/SKILL.md
- [bundled-skills/loki-mode/CLAUDE.md](https://github.com/FrancoStino/opencode-skills-collection/blob/5429d297b3c15ecb8ff510dca17e78e26a98683d/FrancoStino/opencode-skills-collection/blob/main/ FrancoStino/opencode-skills-collection/blob/main/bundled-skills/loki-mode/CLAUDE.md)
- bundled-skills/loki-mode/CONTEXT-EXPORT.md
- bundled-skills/loki-mode/references/tool-orchestration.md (Implicitly referenced via SKILL.md and CLAUDE.md)
Loki Mode is a multi-agent autonomous system designed to transition a Product Requirements Document (PRD) to a fully deployed product with zero human intervention. The core of this autonomy is the RARV Cycle (Reason-Act-Reflect-Verify), a structured iteration loop that ensures every action is justified, executed, reviewed, and tested against specifications.
This operational framework is supported by a multi-tiered Memory System that provides persistent state across execution turns. By utilizing specialized memory types—episodic, semantic, and procedural—Loki Mode can learn from previous failures, maintain context during complex tasks, and optimize agent selection based on historical efficiency metrics.
Sources: bundled-skills/loki-mode/SKILL.md:1-15, bundled-skills/loki-mode/CLAUDE.md:1-10
The RARV Cycle
The RARV Cycle is the mandatory execution protocol for every iteration within Loki Mode. It is designed to minimize errors and prevent "hallucinations" or context loss during autonomous operation.
Cycle Phases
The following table describes the four stages of the cycle:
| Phase | Description | Key Actions |
|---|---|---|
| Reason | Logical planning of the next step. | Read CONTINUITY.md, check task queue, identify priorities. |
| Act | Technical execution of the task. | Dispatch subagents, write code, perform git checkpoints. |
| Reflect | Self-assessment of implementation. | Verify functional success, update working memory. |
| Verify | Automated validation and testing. | Run E2E/Unit tests, check spec compliance, handle failures. |
Sources: bundled-skills/loki-mode/references/core-workflow.md:16-55, bundled-skills/loki-mode/SKILL.md:120-150
Workflow Logic
The RARV cycle includes a self-verification loop that achieves significant quality improvements by forcing the AI to test its own work and learn from failures before proceeding.
The diagram shows the iterative feedback loop within the RARV cycle, specifically how verification failures trigger learning and rollback procedures.
Sources: bundled-skills/loki-mode/references/core-workflow.md:20-55, bundled-skills/loki-mode/SKILL.md:125-150
Memory System Architecture
Loki Mode employs a hierarchical memory structure to manage the vast amount of context generated during the Software Development Life Cycle (SDLC).
Persistent Memory Types
- Episodic Memory: Stores specific interaction traces and interaction logs at
.loki/memory/episodic/. This answers "what happened" in previous steps. - Semantic Memory: Contains generalized patterns and validated knowledge at
.loki/memory/semantic/. This represents "how things work" in the project. - Procedural Memory: Stores learned skills and action sequences at
.loki/memory/skills/. - Working Memory (CONTINUITY.md): The primary source of truth for the current session state. It is read at the start and updated at the end of every turn.
Sources: bundled-skills/loki-mode/SKILL.md:520-545, bundled-skills/loki-mode/CLAUDE.md:38-45, bundled-skills/loki-mode/references/core-workflow.md:112-120
The CONTINUITY.md Protocol
CONTINUITY.md acts as the agent's short-term working memory. It is strictly structured to include the active goal, current task ID, recent accomplishments, and a "Mistakes & Learnings" section.
Protocol Requirements:
- Turn Start: The agent MUST read
CONTINUITY.mdto orient itself. - Turn End: The agent MUST update the file with progress and next actions.
- Error Handling: If an error occurs, the "Mistakes & Learnings" section must be updated with the failed pattern, root cause, and prevention strategy.
Sources: bundled-skills/loki-mode/references/core-workflow.md:73-100, bundled-skills/loki-mode/SKILL.md:13-25
Task Verification & Git Checkpoints
Loki Mode maintains system integrity through a mandatory git checkpoint system. Every completed task triggers an atomic commit, ensuring the system can rollback to a "last known good" state if verification fails later in the SDLC.
Commit Structure
Commits are structured with specific metadata to facilitate autonomous rollbacks:
[Loki] ${agent_type}-${task_id}: ${task_title}
Agent: ${agent_id}
Spec: ${spec_reference}
Tests: ${test_files}
Git-Checkpoint: ${timestamp}
Sources: bundled-skills/loki-mode/references/core-workflow.md:131-165
Verification Logic Sequence
This sequence illustrates the interaction between specialist agents and the underlying safety systems during the Reflect and Verify phases.
Sources: bundled-skills/loki-mode/references/core-workflow.md:135-155, bundled-skills/loki-mode/SKILL.md:140-150
Efficiency Metrics and Tool Orchestration
Drawing inspiration from NVIDIA's ToolOrchestra, Loki Mode tracks efficiency metrics for every task to optimize agent selection in future cycles.
| Metric | Storage Path | Description |
|---|---|---|
| Wall Time | .loki/metrics/efficiency/ | Seconds from start to completion. |
| Agent Count | .loki/metrics/efficiency/ | Number of subagents spawned for the task. |
| Retry Count | .loki/metrics/efficiency/ | Attempts before a successful verification. |
| Rewards | .loki/metrics/rewards/ | Outcome (+1.0/-1.0) and efficiency signals. |
Sources: bundled-skills/loki-mode/SKILL.md:270-300, bundled-skills/loki-mode/CLAUDE.md:47-50
Summary
The combination of the RARV Cycle and a multi-tiered Memory System allows Loki Mode to function autonomously while maintaining high code quality. The RARV cycle provides a rigid framework for execution and testing, while the memory system—anchored by CONTINUITY.md—ensures that the system learns from its own failures and retains context across hundreds of specialized agent interactions.