You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/features/memory.md
+20-26Lines changed: 20 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -73,15 +73,15 @@ The file is only created if it does not already exist. The config is validated o
73
73
"debug": false
74
74
},
75
75
"executionModel": "",
76
+
"auditorModel": "",
76
77
"ralph": {
77
78
"enabled": true,
78
79
"defaultMaxIterations": 15,
79
80
"cleanupWorktree": false,
80
81
"defaultAudit": true,
81
82
"model": "",
82
83
"minAudits": 1
83
-
},
84
-
"auditorModel": ""
84
+
}
85
85
}
86
86
```
87
87
@@ -138,7 +138,7 @@ Set `baseUrl` to point at any OpenAI-compatible self-hosted service (vLLM, Ollam
138
138
|`ralph.defaultAudit`| Run auditor after each coding iteration |`true`|
139
139
|`ralph.model`| Model override for Ralph sessions (`provider/model`), falls back to `executionModel`| — |
140
140
|`ralph.minAudits`| Minimum audit iterations required before completion |`1`|
141
-
|`auditorModel`| Model override for the auditor agent (`provider/model`). Falls back to `ralph.model`, then `executionModel`, then platform default. | — |
141
+
|`auditorModel`| Model override for the auditor agent (`provider/model`). When set, overrides the auditor agent's default model. When not set, the auditor uses the platform default. | — |
142
142
143
143
---
144
144
@@ -197,12 +197,12 @@ The KV service is initialized on plugin startup and begins its cleanup interval
197
197
198
198
The Ralph service manages iterative development loops using the KV store for state persistence:
199
199
200
-
-**State Management**: Each loop's state is stored in the KV store under `ralph:{sessionId}` with fields: `worktreeName`, `phase` (coding/auditing), `iteration`, `goal`, `status` (running/stopped), `audit`, `lastAuditResult`, `errorCount`, `auditCount`
200
+
-**State Management**: Each loop's state is stored in the KV store under `ralph:{sessionId}` with fields: `active` (boolean), `sessionId`, `worktreeName`, `worktreeDir`, `worktreeBranch`, `workspaceId`, `iteration`, `maxIterations`, `completionPromise`, `startedAt`, `prompt`, `phase` (coding/auditing), `audit`, `lastAuditResult`, `errorCount`, `auditCount`, `terminationReason`, `completedAt`, `parentSessionId`, `inPlace`
201
201
-**Two-Phase Cycle**: Alternates between coding (Code agent works on the task) and auditing (Auditor agent reviews changes). Audit findings feed back into the next coding iteration
202
-
-**Completion Criteria**: Requires `minAudits` (default 1) audit iterations before marking the loop as completed
202
+
-**Completion Criteria**: Requires the `completionPromise` to be detected in `<promise>` tags AND `minAudits` (default 1) audit iterations before marking the loop as completed. Without a `completionPromise`, the loop only terminates via other conditions (max iterations, errors, cancellation, etc.)
203
203
-**Error Handling**: Tracks consecutive errors with `MAX_RETRIES` (3). If 3 consecutive iterations fail, the loop terminates with reason `error_max_retries`
204
204
-**Worktree Management**: By default creates an isolated git worktree for each loop. Uses `git rev-parse --git-common-dir` to find the main repo root. On completion, auto-commits changes and removes the worktree (preserving the branch). Set `inPlace: true` to skip worktree isolation
@@ -388,10 +388,11 @@ Create a new Code session and send an implementation plan as the first prompt. D
388
388
|-----------|------|----------|-------------|
389
389
|`plan`| string | Yes | The full implementation plan to send to the Code agent |
390
390
|`title`| string | Yes | Short title for the session (shown in session list, max 60 chars) |
391
+
|`inPlace`| boolean | No | Execute in the current session as a subtask instead of creating a new session (default: false) |
391
392
392
-
Creates a new session via the OpenCode API and sends the plan as the first message to the Code agent. Returns the session ID and title. Only the Architect agent has access to this tool — it is excluded from Code and Memory agents.
393
+
By default, creates a new session via the OpenCode API and sends the plan as the first message to the Code agent. When `inPlace` is true, switches to the Code agent in the current session instead. Returns the session ID and title. Only the Architect agent has access to this tool — it is excluded from Code and Memory agents.
393
394
394
-
The model used for the new Code session is determined by `executionModel` in the plugin config (format: `provider/model`, e.g. `anthropic/claude-sonnet-4-20250514`). If not set, OpenCode's default model resolution is used — typically the `model` field from `opencode.json`.
395
+
The model used for execution is determined by `executionModel` in the plugin config (format: `provider/model`, e.g. `anthropic/claude-sonnet-4-20250514`). If not set, OpenCode's default model resolution is used — typically the `model` field from `opencode.json`.
395
396
396
397
### memory-kv-set
397
398
@@ -440,14 +441,10 @@ Start a Ralph iterative development loop. By default runs in an isolated git wor
440
441
| Parameter | Type | Required | Description |
441
442
|-----------|------|----------|-------------|
442
443
|`prompt`| string | Yes | The task prompt to iterate on |
443
-
|`maxIterations`| number | No | Max iterations before auto-stop (0 = unlimited, default: 15) |
444
444
|`completionPromise`| string | No | Phrase that signals completion when wrapped in `<promise>` tags |
445
445
|`name`| string | No | Name for the worktree branch |
446
-
|`audit`| boolean | No | Run auditor after each iteration (default from config) |
447
446
|`inPlace`| boolean | No | Run in current directory instead of creating a worktree |
448
447
449
-
Creates a new session, initializes Ralph state in the KV store, and sends the prompt. The loop alternates between coding and auditing phases until completion criteria are met.
450
-
451
448
### ralph-cancel
452
449
453
450
Cancel an active Ralph loop and optionally clean up the worktree.
@@ -474,12 +471,8 @@ Execute an architect plan using a Ralph iterative development loop. Designed to
474
471
|-----------|------|----------|-------------|
475
472
|`plan`| string | Yes | The full implementation plan |
476
473
|`title`| string | Yes | Short title for the session |
477
-
|`maxIterations`| number | No | Max iterations (0 = unlimited, default: 15) |
478
-
|`audit`| boolean | No | Run auditor after each iteration (default: true) |
479
474
|`inPlace`| boolean | No | Run in current directory instead of worktree (default: false) |
480
475
481
-
The model used is determined by `ralph.model` in the config, falling back to `executionModel`, then to OpenCode's default model. Only the Architect agent has access to this tool.
482
-
483
476
!!! note "KV Store vs Memory"
484
477
The KV store is designed for **ephemeral** project state that expires automatically (default 24 hours). Use `memory-write` for **durable** knowledge that should persist across sessions, such as conventions, decisions, and context.
485
478
@@ -536,11 +529,13 @@ The Ralph loop is an iterative development system that alternates between coding
536
529
-**Coding phase** → If auditing is enabled, switches to auditing phase and runs the Auditor agent as a subtask
537
530
-**Auditing phase** → Processes audit findings, switches back to coding phase, and sends a continuation prompt with the findings
538
531
4. The loop repeats until one of these conditions is met:
-**Completion**: The `completionPromise` phrase is detected in `<promise>` tags AND `minAudits` (default 1) audit iterations have been performed. Without a `completionPromise`, the loop does not auto-complete.
-**Stall timeout**: 5 consecutive stalls detected by the watchdog (`MAX_CONSECUTIVE_STALLS`)
542
536
-**Worktree failure**: The worktree becomes unavailable
543
537
-**Cancelled**: User cancels via `ralph-cancel` or `/cancel-ralph`
538
+
-**User abort**: Session is aborted
544
539
545
540
#### Worktree vs In-Place
546
541
@@ -724,22 +719,21 @@ Defense-in-depth companion to `tool.execute.before`. If a blocked tool somehow e
724
719
725
720
### permission.ask
726
721
727
-
Auto-resolves file operation permissions during Ralph loops:
722
+
Auto-resolves permissions during Ralph loops:
728
723
729
-
-**Allow**: File operations (read, write, edit) within the Ralph worktree directory
730
724
-**Deny**: `git push` operations (always denied during Ralph loops)
731
-
-**Deny**: File operations outside the worktree directory (prevents `../` traversal via `resolve()` path normalization)
732
-
733
-
For in-place Ralph loops, worktree-scoped permission checks are skipped (only git push is denied).
725
+
- All other permission requests are passed through to the default handler
734
726
735
727
### session.idle (event handler)
736
728
737
729
Drives the Ralph iteration loop by listening for `session.idle` events:
738
730
739
731
1. Checks if the idle session belongs to an active Ralph loop
740
-
2. If in **coding phase** and auditing is enabled: switches to auditing phase, runs the Auditor agent as a subtask
741
-
3. If in **auditing phase**: processes audit findings, increments clean audit count (or resets on findings), switches back to coding phase, sends continuation prompt
2. Records activity to reset the watchdog stall timer
733
+
3. Re-fetches state as a safety check against race conditions
734
+
4. Dispatches to the appropriate phase handler:
735
+
-**Coding phase**: If auditing is enabled, switches to auditing phase and runs the Auditor agent as a subtask. Checks for completion promise. Checks max iterations.
736
+
-**Auditing phase**: Processes audit results, increments `auditCount`, switches back to coding phase, sends continuation prompt with findings. Checks for completion promise. Checks max iterations.
Copy file name to clipboardExpand all lines: packages/memory/README.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -223,15 +223,15 @@ You can edit this file to customize settings. The file is created only if it doe
223
223
"debug": false
224
224
},
225
225
"executionModel": "",
226
+
"auditorModel": "",
226
227
"ralph": {
227
228
"enabled": true,
228
229
"defaultMaxIterations": 15,
229
230
"cleanupWorktree": false,
230
231
"defaultAudit": true,
231
232
"model": "",
232
233
"minAudits": 1
233
-
},
234
-
"auditorModel": ""
234
+
}
235
235
}
236
236
```
237
237
@@ -302,7 +302,7 @@ When enabled, logs are written to the specified file with timestamps. The log fi
302
302
-`ralph.minAudits` - Minimum audit iterations required before completion (default: `1`)
303
303
304
304
#### Auditor
305
-
-`auditorModel` - Model override for the auditor agent (`provider/model`). Falls back to `ralph.model`, then `executionModel`, then platform default (default: `""`)
305
+
-`auditorModel` - Model override for the auditor agent (`provider/model`). When set, overrides the auditor agent's default model. When not set, uses platform default (default: `""`)
0 commit comments