Skip to content

Commit 48fc1e3

Browse files
Fix documentation-code mismatches in memory plugin docs
1 parent b6ab0bc commit 48fc1e3

2 files changed

Lines changed: 23 additions & 29 deletions

File tree

docs/features/memory.md

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,15 @@ The file is only created if it does not already exist. The config is validated o
7373
"debug": false
7474
},
7575
"executionModel": "",
76+
"auditorModel": "",
7677
"ralph": {
7778
"enabled": true,
7879
"defaultMaxIterations": 15,
7980
"cleanupWorktree": false,
8081
"defaultAudit": true,
8182
"model": "",
8283
"minAudits": 1
83-
},
84-
"auditorModel": ""
84+
}
8585
}
8686
```
8787

@@ -138,7 +138,7 @@ Set `baseUrl` to point at any OpenAI-compatible self-hosted service (vLLM, Ollam
138138
| `ralph.defaultAudit` | Run auditor after each coding iteration | `true` |
139139
| `ralph.model` | Model override for Ralph sessions (`provider/model`), falls back to `executionModel` ||
140140
| `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. ||
142142

143143
---
144144

@@ -197,12 +197,12 @@ The KV service is initialized on plugin startup and begins its cleanup interval
197197

198198
The Ralph service manages iterative development loops using the KV store for state persistence:
199199

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`
201201
- **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.)
203203
- **Error Handling**: Tracks consecutive errors with `MAX_RETRIES` (3). If 3 consecutive iterations fail, the loop terminates with reason `error_max_retries`
204204
- **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
205-
- **Termination Reasons**: `completed`, `max_iterations`, `error_max_retries`, `worktree_failed`, `cancelled`
205+
- **Termination Reasons**: `completed`, `max_iterations`, `error_max_retries`, `worktree_failed`, `cancelled`, `user_aborted`, `stall_timeout`, `shutdown`
206206

207207
### Vector Search
208208

@@ -388,10 +388,11 @@ Create a new Code session and send an implementation plan as the first prompt. D
388388
|-----------|------|----------|-------------|
389389
| `plan` | string | Yes | The full implementation plan to send to the Code agent |
390390
| `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) |
391392

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.
393394

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`.
395396

396397
### memory-kv-set
397398

@@ -440,14 +441,10 @@ Start a Ralph iterative development loop. By default runs in an isolated git wor
440441
| Parameter | Type | Required | Description |
441442
|-----------|------|----------|-------------|
442443
| `prompt` | string | Yes | The task prompt to iterate on |
443-
| `maxIterations` | number | No | Max iterations before auto-stop (0 = unlimited, default: 15) |
444444
| `completionPromise` | string | No | Phrase that signals completion when wrapped in `<promise>` tags |
445445
| `name` | string | No | Name for the worktree branch |
446-
| `audit` | boolean | No | Run auditor after each iteration (default from config) |
447446
| `inPlace` | boolean | No | Run in current directory instead of creating a worktree |
448447

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-
451448
### ralph-cancel
452449

453450
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
474471
|-----------|------|----------|-------------|
475472
| `plan` | string | Yes | The full implementation plan |
476473
| `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) |
479474
| `inPlace` | boolean | No | Run in current directory instead of worktree (default: false) |
480475

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-
483476
!!! note "KV Store vs Memory"
484477
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.
485478

@@ -536,11 +529,13 @@ The Ralph loop is an iterative development system that alternates between coding
536529
- **Coding phase** → If auditing is enabled, switches to auditing phase and runs the Auditor agent as a subtask
537530
- **Auditing phase** → Processes audit findings, switches back to coding phase, and sends a continuation prompt with the findings
538531
4. The loop repeats until one of these conditions is met:
539-
- **Completion**: `minAudits` (default 1) audit iterations
540-
- **Max iterations**: Reached `maxIterations` limit (if set)
532+
- **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.
533+
- **Max iterations**: Reached `maxIterations` limit (if > 0)
541534
- **Error limit**: 3 consecutive failures (`MAX_RETRIES`)
535+
- **Stall timeout**: 5 consecutive stalls detected by the watchdog (`MAX_CONSECUTIVE_STALLS`)
542536
- **Worktree failure**: The worktree becomes unavailable
543537
- **Cancelled**: User cancels via `ralph-cancel` or `/cancel-ralph`
538+
- **User abort**: Session is aborted
544539

545540
#### Worktree vs In-Place
546541

@@ -724,22 +719,21 @@ Defense-in-depth companion to `tool.execute.before`. If a blocked tool somehow e
724719

725720
### permission.ask
726721

727-
Auto-resolves file operation permissions during Ralph loops:
722+
Auto-resolves permissions during Ralph loops:
728723

729-
- **Allow**: File operations (read, write, edit) within the Ralph worktree directory
730724
- **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
734726

735727
### session.idle (event handler)
736728

737729
Drives the Ralph iteration loop by listening for `session.idle` events:
738730

739731
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
742-
4. Checks termination conditions (clean audit threshold, max iterations, error limit)
732+
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.
743737
5. On completion: auto-commits changes (worktree mode), removes worktree (preserving branch), notifies parent session
744738

745739
### worktree.failed (event handler)

packages/memory/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,15 +223,15 @@ You can edit this file to customize settings. The file is created only if it doe
223223
"debug": false
224224
},
225225
"executionModel": "",
226+
"auditorModel": "",
226227
"ralph": {
227228
"enabled": true,
228229
"defaultMaxIterations": 15,
229230
"cleanupWorktree": false,
230231
"defaultAudit": true,
231232
"model": "",
232233
"minAudits": 1
233-
},
234-
"auditorModel": ""
234+
}
235235
}
236236
```
237237

@@ -302,7 +302,7 @@ When enabled, logs are written to the specified file with timestamps. The log fi
302302
- `ralph.minAudits` - Minimum audit iterations required before completion (default: `1`)
303303

304304
#### 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: `""`)
306306

307307
## architect → code Workflow
308308

0 commit comments

Comments
 (0)