diff --git a/src/agents/pi-embedded-runner/compact.ts b/src/agents/pi-embedded-runner/compact.ts index 7dba07dd2cb..587a0e9214d 100644 --- a/src/agents/pi-embedded-runner/compact.ts +++ b/src/agents/pi-embedded-runner/compact.ts @@ -53,6 +53,7 @@ import { supportsModelTools } from "../model-tool-support.js"; import { ensureOpenClawModelsJson } from "../models-config.js"; import { createConfiguredOllamaStreamFn } from "../ollama-stream.js"; import { resolveOwnerDisplaySetting } from "../owner-display.js"; +import { createBundleLspToolRuntime } from "../pi-bundle-lsp-runtime.js"; import { createBundleMcpToolRuntime } from "../pi-bundle-mcp-tools.js"; import { ensureSessionHeader, @@ -603,10 +604,21 @@ export async function compactEmbeddedPiSessionDirect( reservedToolNames: tools.map((tool) => tool.name), }) : undefined; - const effectiveTools = - bundleMcpRuntime && bundleMcpRuntime.tools.length > 0 - ? [...tools, ...bundleMcpRuntime.tools] - : tools; + const bundleLspRuntime = toolsEnabled + ? await createBundleLspToolRuntime({ + workspaceDir: effectiveWorkspace, + cfg: params.config, + reservedToolNames: [ + ...tools.map((tool) => tool.name), + ...(bundleMcpRuntime?.tools.map((tool) => tool.name) ?? []), + ], + }) + : undefined; + const effectiveTools = [ + ...tools, + ...(bundleMcpRuntime?.tools ?? []), + ...(bundleLspRuntime?.tools ?? []), + ]; const allowedToolNames = collectAllowedToolNames({ tools: effectiveTools }); logToolSchemasForGoogle({ tools: effectiveTools, provider }); const machineName = await getMachineDisplayName(); @@ -1092,6 +1104,7 @@ export async function compactEmbeddedPiSessionDirect( }); session.dispose(); await bundleMcpRuntime?.dispose(); + await bundleLspRuntime?.dispose(); } } finally { await sessionLock.release(); diff --git a/src/agents/pi-embedded-runner/run/attempt.ts b/src/agents/pi-embedded-runner/run/attempt.ts index 69d8212adfa..3c77d877e28 100644 --- a/src/agents/pi-embedded-runner/run/attempt.ts +++ b/src/agents/pi-embedded-runner/run/attempt.ts @@ -61,6 +61,7 @@ import { supportsModelTools } from "../../model-tool-support.js"; import { createConfiguredOllamaStreamFn } from "../../ollama-stream.js"; import { createOpenAIWebSocketStreamFn, releaseWsSession } from "../../openai-ws-stream.js"; import { resolveOwnerDisplaySetting } from "../../owner-display.js"; +import { createBundleLspToolRuntime } from "../../pi-bundle-lsp-runtime.js"; import { createBundleMcpToolRuntime } from "../../pi-bundle-mcp-tools.js"; import { downgradeOpenAIFunctionCallReasoningPairs, @@ -1570,10 +1571,22 @@ export async function runEmbeddedAttempt( ], }) : undefined; - const effectiveTools = - bundleMcpRuntime && bundleMcpRuntime.tools.length > 0 - ? [...tools, ...bundleMcpRuntime.tools] - : tools; + const bundleLspRuntime = toolsEnabled + ? await createBundleLspToolRuntime({ + workspaceDir: effectiveWorkspace, + cfg: params.config, + reservedToolNames: [ + ...tools.map((tool) => tool.name), + ...(clientTools?.map((tool) => tool.function.name) ?? []), + ...(bundleMcpRuntime?.tools.map((tool) => tool.name) ?? []), + ], + }) + : undefined; + const effectiveTools = [ + ...tools, + ...(bundleMcpRuntime?.tools ?? []), + ...(bundleLspRuntime?.tools ?? []), + ]; const allowedToolNames = collectAllowedToolNames({ tools: effectiveTools, clientTools, @@ -2913,6 +2926,7 @@ export async function runEmbeddedAttempt( session?.dispose(); releaseWsSession(params.sessionId); await bundleMcpRuntime?.dispose(); + await bundleLspRuntime?.dispose(); await sessionLock.release(); } } finally {