Skip to content

feat(rlm): default to 20 iterations with REPL_RLM_MAX_ITERATIONS override - #243

Merged
AdarGit008 merged 2 commits into
mainfrom
feat/rlm-max-iterations-default
Oct 7, 2026
Merged

AdarGit008 merged 2 commits into
mainfrom
feat/rlm-max-iterations-default

Conversation

@AdarGit008

Copy link
Copy Markdown
Owner

What

The rlm code-gen → execute loop was hard-capped at 10 iterations with no way to raise it: a model-supplied maxIterations was clamped to the same 10 that served as the default, so the loop could never run more turns regardless of the question.

This raises the default to 20 and mirrors the existing REPL_RLM_BUDGET knob with a new REPL_RLM_MAX_ITERATIONS env var, which sets both the default and the ceiling on a model-supplied maxIterations.

Changes

  • src/rlm.ts — export DEFAULT_RLM_MAX_ITERATIONS (20); runRlm falls back to it instead of ?? 10
  • src/model_boundary.ts — defaultRlmMaxIterations() reads REPL_RLM_MAX_ITERATIONS; clampRlmLimits caps maxIterations at that value instead of a hard-coded 10
  • extensions/repl-extension.ts + src/mcp_server.ts — the rlm tool and /rlm command pass the overridable default explicitly (matching how budget is already handled)
  • tests — update the three default/ceiling assertions and add REPL_RLM_MAX_ITERATIONS override coverage

Usage

REPL_RLM_MAX_ITERATIONS=40 pi   # more turns (restart pi to pick up the env var)
REPL_RLM_BUDGET=1000000 pi      # raise the spend ceiling too, if hitting budget_exhausted

Note: iterations and budget are independent limits — the result's status: field shows which one stopped the loop (max_iterations vs budget_exhausted).

Verification

wf gate → all four steps pass (lint, typecheck, test, build).

Also includes a one-line chore commit syncing package-lock.json's bin entry (a byproduct of npm install after the MCP bin was added upstream).

…ride

The rlm code-gen → execute loop was hard-capped at 10 iterations with no way to raise it: a model-supplied maxIterations was clamped to the same 10 that served as the default, so the loop could never run more turns.

Raise the default to 20 and mirror the existing REPL_RLM_BUDGET knob with REPL_RLM_MAX_ITERATIONS, which sets both the default and the ceiling on a model-supplied maxIterations.

- src/rlm.ts: export DEFAULT_RLM_MAX_ITERATIONS (20); runRlm falls back to it
- src/model_boundary.ts: defaultRlmMaxIterations() reads REPL_RLM_MAX_ITERATIONS; clampRlmLimits caps maxIterations at that value instead of a hard-coded 10
- extensions/repl-extension.ts + src/mcp_server.ts: the rlm tool and /rlm command pass the overridable default explicitly
- tests: update default/ceiling assertions and add env-override coverage
@AdarGit008
AdarGit008 merged commit 1ea70d8 into main Oct 7, 2026
12 checks passed
@AdarGit008
AdarGit008 deleted the feat/rlm-max-iterations-default branch October 7, 2026 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant