The open source coding agent.
TypeScript
fix mcp tools corrupting session
Dax Raad0d50c867ff16
diff --git a/opencode.json b/opencode.jsonindex 57b9400824d..ff206980da7 100644--- a/opencode.json+++ b/opencode.json@@ -1,5 +1,11 @@{"$schema": "https://opencode.ai/config.json",+ "mcp": {+ "weather": {+ "type": "local",+ "command": ["opencode", "x", "@h1deya/mcp-server-weather"]+ }+ },"experimental": {"hook": {"file_edited": {diff --git a/packages/opencode/src/session/index.ts b/packages/opencode/src/session/index.tsindex 4c50d51d5aa..4e24fa517d4 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.executeif (!execute) continueitem.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