Skip to content

Commit 4e9770d

Browse files
ziggyclaude
andcommitted
fix: reduce Ralph default from 50 to 10 iterations, make configurable
50 was excessive for typical overnight task lists. Now defaults to 10. Configurable via RALPH_MAX_ITERATIONS in .env or per-run. The /run-ralph skill now counts tasks and sets iterations to task count + 2 (buffer for retries), or asks the user. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 700656d commit 4e9770d

4 files changed

Lines changed: 20 additions & 7 deletions

File tree

.claude/skills/run-ralph/SKILL.md

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,22 +39,29 @@ Rules for good task files:
3939
sqlite3 store/messages.db "SELECT jid FROM registered_groups WHERE folder = 'main' LIMIT 1;"
4040
```
4141

42-
### 3. Start the run
42+
### 3. Set iterations
43+
44+
Count the unchecked tasks in the task file. Set `maxIterations` to that count + 2 (buffer for retries). If unsure, ask the user: "You have N tasks — run all of them, or set a limit?"
45+
46+
Default is 10 if not specified. Can also be set via `RALPH_MAX_ITERATIONS` in `.env`.
47+
48+
### 4. Start the run
4349

4450
Write an IPC file:
4551

4652
```bash
4753
CHAT_JID="<main chat JID>"
4854
TASK_FILE="/absolute/path/to/tasks.md"
4955
WORK_DIR="/absolute/path/to/project"
56+
MAX_ITER=<task count + 2>
5057

5158
cat > data/ipc/main/tasks/ralph_start_$(date +%s).json << EOF
5259
{
5360
"type": "start_ralph",
5461
"taskFile": "$TASK_FILE",
5562
"workDir": "$WORK_DIR",
5663
"targetJid": "$CHAT_JID",
57-
"maxIterations": 50,
64+
"maxIterations": $MAX_ITER,
5865
"notifyProgress": true
5966
}
6067
EOF
@@ -65,7 +72,7 @@ The bot will message you: "Ralph run started: ralph-{id}"
6572
### 4. Monitor progress
6673

6774
Between each iteration, the bot messages you:
68-
> Ralph [3/50]: Completed "Add login endpoint with JWT"
75+
> Ralph [3/7]: Completed "Add login endpoint with JWT"
6976
7077
Check detailed progress:
7178
```bash
@@ -111,7 +118,7 @@ The task file will have all checkboxes marked `[x]`.
111118
## Safety
112119

113120
- Each iteration runs in **isolated context** (fresh agent, no carried-over confusion)
114-
- Max 50 iterations by default (configurable via `maxIterations`)
121+
- Max 10 iterations by default (configurable via `maxIterations` or `RALPH_MAX_ITERATIONS` in `.env`)
115122
- Tasks that fail 3 times are skipped (configurable via `maxFailuresPerTask` in config.json)
116123
- Agent is instructed to **commit after each task** — easy to roll back
117124
- You can stop the loop at any time via the stop IPC command

src/config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const envConfig = readEnvFile([
1212
'TELEGRAM_ONLY',
1313
'AGENT_IDLE_TIMEOUT',
1414
'AGENT_ABSOLUTE_TIMEOUT',
15+
'RALPH_MAX_ITERATIONS',
1516
]);
1617

1718
export const ASSISTANT_NAME =
@@ -55,6 +56,11 @@ export const AGENT_ABSOLUTE_TIMEOUT = parseInt(
5556
'2700000',
5657
10,
5758
); // 45 min default
59+
export const RALPH_MAX_ITERATIONS = parseInt(
60+
process.env.RALPH_MAX_ITERATIONS || envConfig.RALPH_MAX_ITERATIONS || '10',
61+
10,
62+
); // 10 steps default — override in .env or per-run
63+
5864
export const MAX_CONCURRENT_CONTAINERS = Math.max(
5965
1,
6066
parseInt(process.env.MAX_CONCURRENT_CONTAINERS || '5', 10) || 5,

src/ralph-runner.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('startRalphRun', () => {
127127
k.endsWith('config.json'),
128128
)!;
129129
const config = JSON.parse(deps.files[configKey]);
130-
expect(config.maxIterations).toBe(50);
130+
expect(config.maxIterations).toBe(10);
131131
expect(config.maxFailuresPerTask).toBe(3);
132132
});
133133
});

src/ralph-runner.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
import path from 'path';
88

9-
import { DATA_DIR } from './config.js';
9+
import { DATA_DIR, RALPH_MAX_ITERATIONS } from './config.js';
1010
import { logger } from './logger.js';
1111
import {
1212
RalphConfig,
@@ -165,7 +165,7 @@ export async function startRalphRun(
165165
workDir: params.workDir,
166166
targetJid: params.targetJid,
167167
groupFolder: params.groupFolder,
168-
maxIterations: params.maxIterations ?? 50,
168+
maxIterations: params.maxIterations ?? RALPH_MAX_ITERATIONS,
169169
maxFailuresPerTask: params.maxFailuresPerTask ?? 3,
170170
currentIteration: 0,
171171
consecutiveFailures: {},

0 commit comments

Comments
 (0)