From f667092c32fec7b43bb0729f8dbdad47cd9f7e62 Mon Sep 17 00:00:00 2001 From: Seth Date: Mon, 17 Aug 2026 15:21:40 -0700 Subject: [PATCH 1/2] feat(coding-agent): default RLM max depth to 2 --- packages/coding-agent/CHANGELOG.md | 1 + packages/coding-agent/docs/rlm-runtime.md | 2 +- packages/coding-agent/src/core/agent-session.ts | 4 ++-- packages/coding-agent/src/core/settings-manager.ts | 2 +- packages/coding-agent/test/agent-session-recursion.test.ts | 6 +++--- 5 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/coding-agent/CHANGELOG.md b/packages/coding-agent/CHANGELOG.md index 1c0be2a5ac..c0931c423a 100644 --- a/packages/coding-agent/CHANGELOG.md +++ b/packages/coding-agent/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Changed the default RLM maximum recursion depth for new sessions from 1 to 2. - Fixed the agent going silent after an automatic context compaction interrupted unfinished work: the tool loop now resumes when a threshold compaction fails or is skipped, and active goals keep continuing after a successful mid-goal threshold compaction. - Changed the agents view splash hint from "type to start" to "type to search sessions". - Added `app.edits.expand` (`ctrl+j`) to toggle edit diffs; diffs are now shown only by this toggle, and `ctrl+o` no longer affects them. diff --git a/packages/coding-agent/docs/rlm-runtime.md b/packages/coding-agent/docs/rlm-runtime.md index 4de095cf01..15471e9311 100644 --- a/packages/coding-agent/docs/rlm-runtime.md +++ b/packages/coding-agent/docs/rlm-runtime.md @@ -168,7 +168,7 @@ Unknown options fail instead of being ignored. Model search is bounded to active 7. 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 Delegation diff --git a/packages/coding-agent/src/core/agent-session.ts b/packages/coding-agent/src/core/agent-session.ts index 38b1c3be88..f6cba6dc58 100644 --- a/packages/coding-agent/src/core/agent-session.ts +++ b/packages/coding-agent/src/core/agent-session.ts @@ -465,7 +465,7 @@ export interface AgentSessionConfig { sessionStartEvent?: SessionStartEvent; /** Current RLM recursion depth. Root sessions default to RLM_DEPTH or 0. */ rlmDepth?: number; - /** Maximum RLM recursion depth. Defaults to RLM_MAX_DEPTH or 1. */ + /** Maximum RLM recursion depth. Defaults to RLM_MAX_DEPTH or 2. */ rlmMaxDepth?: number; /** Directory exposed to the kernel as RLM_SESSION_DIR. */ rlmSessionDir?: string; @@ -1594,7 +1594,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.ts index d221ccc7e5..74dadc1e4b 100644 --- a/packages/coding-agent/src/core/settings-manager.ts +++ b/packages/coding-agent/src/core/settings-manager.ts @@ -127,7 +127,7 @@ export interface Settings { recentModels?: string[]; // "provider/id" keys, most-recently-used first defaultThinkingLevel?: "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 2 idleEvictionMinutes?: number | "off"; // global daemon policy; default: 90 transport?: 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.ts index f066f02b11..5b68c0617d 100644 --- a/packages/coding-agent/test/agent-session-recursion.test.ts +++ b/packages/coding-agent/test/agent-session-recursion.test.ts @@ -1852,7 +1852,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); @@ -1969,7 +1969,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" }); @@ -2047,7 +2047,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.sessionManager From 359a073ed5ae58911f26e7785515142dfde36fa5 Mon Sep 17 00:00:00 2001 From: Seth Date: Mon, 17 Aug 2026 15:35:27 -0700 Subject: [PATCH 2/2] test(coding-agent): pin max depth in prompt update case --- packages/coding-agent/test/suite/agent-session-prompt.test.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/coding-agent/test/suite/agent-session-prompt.test.ts b/packages/coding-agent/test/suite/agent-session-prompt.test.ts index 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) => ({