From 0d50c867ff16686d47101fa6d29e07539fe40d8f Mon Sep 17 00:00:00 2001 From: Dax Raad Date: Mon, 7 Jul 2025 17:05:16 -0400 Subject: fix mcp tools corrupting session --- packages/opencode/src/session/index.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'packages') diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.ts index 4c50d51d5..4e24fa517 100644 --- a/packages/opencode/src/session/index.ts +++ b/packages/opencode/src/session/index.ts @@ -496,14 +496,20 @@ export namespace Session { const execute = item.execute if (!execute) continue item.execute = async (args, opts) => { - try { - const result = await execute(args, opts) - return result.content - .filter((x: any) => x.type === "text") - .map((x: any) => x.text) - .join("\n\n") - } catch (e: any) { - return e.toString() + const result = await execute(args, opts) + const output = result.content + .filter((x: any) => x.type === "text") + .map((x: any) => x.text) + .join("\n\n") + + return { + output, + } + } + item.toModelOutput = (result) => { + return { + type: "text", + value: result.output, } } tools[key] = item -- cgit v1.2.3