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
This commit is contained in:
roboomp
2026-05-26 03:06:14 +00:00
parent 5ff1c747ce
commit 8948101e2b
2 changed files with 22 additions and 1 deletions
+2
View File
@@ -888,6 +888,7 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
persistArtifacts: !!artifactsDir,
artifactsDir: effectiveArtifactsDir,
contextFile: contextFilePath,
enableLsp: this.session.enableLsp,
signal,
eventBus: this.session.eventBus,
onProgress: progress => {
@@ -942,6 +943,7 @@ export class TaskTool implements AgentTool<TaskToolSchemaInstance, TaskToolDetai
persistArtifacts: !!artifactsDir,
artifactsDir: effectiveArtifactsDir,
contextFile: contextFilePath,
enableLsp: this.session.enableLsp,
signal,
eventBus: this.session.eventBus,
onProgress: progress => {
@@ -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",