From 8948101e2bfcec29601ff09d8f8b2ed9304fc514 Mon Sep 17 00:00:00 2001 From: roboomp Date: Tue, 26 May 2026 03:06:14 +0000 Subject: [PATCH] fix(task): forwarded parent enableLsp flag to subagents Subagents now inherit the parent session's enableLsp value, so a top-level --no-lsp invocation propagates into spawned tasks instead of falling back to the executor's default of true. Fixes #1385 --- packages/coding-agent/src/task/index.ts | 2 ++ .../test/task/subagent-lsp.test.ts | 21 ++++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/coding-agent/src/task/index.ts b/packages/coding-agent/src/task/index.ts index a0d6a9a6b..380db42a6 100644 --- a/packages/coding-agent/src/task/index.ts +++ b/packages/coding-agent/src/task/index.ts @@ -888,6 +888,7 @@ export class TaskTool implements AgentTool { @@ -942,6 +943,7 @@ export class TaskTool implements AgentTool { diff --git a/packages/coding-agent/test/task/subagent-lsp.test.ts b/packages/coding-agent/test/task/subagent-lsp.test.ts index ef34d9ce6..c9ef34b83 100644 --- a/packages/coding-agent/test/task/subagent-lsp.test.ts +++ b/packages/coding-agent/test/task/subagent-lsp.test.ts @@ -86,7 +86,9 @@ function createYieldingSession(): AgentSession { } as unknown as AgentSession; } -function createSession(options: { isolationMode?: "none" | "auto"; planMode?: PlanModeState } = {}): ToolSession { +function createSession( + options: { enableLsp?: boolean; isolationMode?: "none" | "auto"; planMode?: PlanModeState } = {}, +): ToolSession { const modelRegistry = { authStorage: undefined, refresh: async () => {}, @@ -98,6 +100,7 @@ function createSession(options: { isolationMode?: "none" | "auto"; planMode?: Pl cwd: "/tmp", hasUI: false, settings: Settings.isolated({ "async.enabled": false, "task.isolation.mode": options.isolationMode ?? "none" }), + enableLsp: options.enableLsp, getSessionFile: () => null, getSessionSpawns: () => "*", modelRegistry, @@ -174,6 +177,22 @@ describe("subagent LSP availability", () => { expect(getOptions()?.toolNames).toContain("lsp"); }); + it("propagates the parent --no-lsp flag into subagents", async () => { + mockAgents({ + name: "task", + description: "Task agent", + systemPrompt: "Use normal tools.", + source: "bundled", + tools: ["lsp"], + }); + const { getOptions } = mockCreateAgentSession(); + + const tool = await TaskTool.create(createSession({ enableLsp: false })); + await tool.execute("tool-call", TEST_TASK); + + expect(getOptions()?.enableLsp).toBe(false); + }); + it("inherits the executor default instead of disabling LSP for isolated subagents", async () => { mockAgents({ name: "task",