A self-improving RLM agent for coding workflows and long-running autonomous tasks.
Rust
feat(coding-agent): default RLM max depth to 2 (#1493)
Seth Karten9e49b73dd469
diff --git a/packages/coding-agent/.changes/fix-rlm-default-max-depth-2.md b/packages/coding-agent/.changes/fix-rlm-default-max-depth-2.mdnew file mode 100644index 0000000000..61690d1daa--- /dev/null+++ b/packages/coding-agent/.changes/fix-rlm-default-max-depth-2.md@@ -0,0 +1 @@+- Changed the default RLM maximum recursion depth for new sessions from 1 to 2.diff --git a/packages/coding-agent/docs/rlm-runtime.md b/packages/coding-agent/docs/rlm-runtime.mdindex 39573e7a80..332ea3f03b 100644--- a/packages/coding-agent/docs/rlm-runtime.md+++ b/packages/coding-agent/docs/rlm-runtime.md@@ -169,7 +169,7 @@ Unknown options fail instead of being ignored. Model search is bounded to active7. Run the child prompt, retain its session, and update lifecycle state independently of the admission call.8. Attribute child usage to the parent assistant turn and persist the attribution.-Children receive incremented `RLM_DEPTH`, the inherited maximum depth, and their own `RLM_SESSION_DIR`. The default maximum depth is 1, so root sessions may create children and those children may not create grandchildren unless the limit is configured higher.+Children receive incremented `RLM_DEPTH`, the inherited maximum depth, and their own `RLM_SESSION_DIR`. The default maximum depth is 2, so root sessions may create children and grandchildren; grandchildren may not create another generation unless the limit is configured higher.## Independent Delegationdiff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.tsindex d2befaaf7f..96a4dce54d 100644--- a/packages/coding-agent/src/core/agent-session.ts+++ b/packages/coding-agent/src/core/agent-session.ts@@ -1586,7 +1586,7 @@ export class AgentSession {if (env !== undefined && env !== "") {return { maxDepth: parseDepth(env, 1, "RLM_MAX_DEPTH"), source: "env" };}- return { maxDepth: 1, source: "default" };+ return { maxDepth: 2, source: "default" };}private _loadPersistedGoalState(): GoalState {diff --git a/packages/coding-agent/src/core/settings-manager.ts b/packages/coding-agent/src/core/settings-manager.tsindex e3d69945f8..0b8d309b0d 100644--- a/packages/coding-agent/src/core/settings-manager.ts+++ b/packages/coding-agent/src/core/settings-manager.ts@@ -133,7 +133,7 @@ export interface Settings {recentModels?: string[]; // "provider/id" keys, most-recently-used firstdefaultThinkingLevel?: "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";defaultServiceTier?: ServiceTier;- rlmMaxDepth?: number; // default for new sessions; unset falls through to RLM_MAX_DEPTH, then 1+ rlmMaxDepth?: number; // default for new sessions; unset falls through to RLM_MAX_DEPTH, then 2idleEvictionMinutes?: number | "off"; // global daemon policy; default: 90transport?: TransportSetting; // default: "auto"steeringMode?: "all" | "one-at-a-time";diff --git a/packages/coding-agent/test/agent-session-recursion.test.ts b/packages/coding-agent/test/agent-session-recursion.test.tsindex 63afdc6169..4b5b7b9e29 100644--- a/packages/coding-agent/test/agent-session-recursion.test.ts+++ b/packages/coding-agent/test/agent-session-recursion.test.ts@@ -2481,7 +2481,7 @@ describe("AgentSession rlm recursion", () => {const root = createSession();const originalMessages = [...root.messages];- expect(root.getRlmMaxDepthStatus()).toEqual({ maxDepth: 1, source: "default" });+ expect(root.getRlmMaxDepthStatus()).toEqual({ maxDepth: 2, source: "default" });await expect(root.setRlmMaxDepth(-1)).rejects.toThrow("non-negative integer");await root.setRlmMaxDepth(3);@@ -2598,7 +2598,7 @@ describe("AgentSession rlm recursion", () => {source: "chat",globalSaved: true,});- expect(existing.rlmMaxDepth).toBe(1);+ expect(existing.rlmMaxDepth).toBe(2);const freshSettings = SettingsManager.create(tempDir, tempDir);const fresh = createSession({ settingsManager: freshSettings });expect(fresh.getRlmMaxDepthStatus()).toEqual({ maxDepth: 4, source: "global" });@@ -2676,7 +2676,7 @@ describe("AgentSession rlm recursion", () => {});await expect(root.setRlmMaxDepth(0)).rejects.toThrow("disk full");- expect(root.rlmMaxDepth).toBe(1);+ expect(root.rlmMaxDepth).toBe(2);expect(root.systemPrompt).toBe(originalPrompt);expect(root.sessionManagerdiff --git a/packages/coding-agent/test/suite/agent-session-prompt.test.ts b/packages/coding-agent/test/suite/agent-session-prompt.test.tsindex 8cec019947..8ade5795d0 100644--- a/packages/coding-agent/test/suite/agent-session-prompt.test.ts+++ b/packages/coding-agent/test/suite/agent-session-prompt.test.ts@@ -463,6 +463,7 @@ describe("AgentSession prompt characterization", () => {const responseGate = createDeferred();const harness = await createHarness({rlmDepth: 1,+ rlmMaxDepth: 1,extensionFactories: [(pi) => {pi.on("before_agent_start", async (event) => ({