From 300232932d00aea920e4e09bfc21f2fad00023e5 Mon Sep 17 00:00:00 2001 From: Shivaditya Shivganesh Date: Thu, 9 Jan 2025 14:51:49 -0500 Subject: [PATCH] fix: data type issue with the write_tool --- src/adapters/openai/helpers/completions.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/adapters/openai/helpers/completions.ts b/src/adapters/openai/helpers/completions.ts index c916df1f..26be24e7 100644 --- a/src/adapters/openai/helpers/completions.ts +++ b/src/adapters/openai/helpers/completions.ts @@ -202,6 +202,12 @@ export class Completions extends SuperOpenAi { try { const toolRequest: ToolRequest = JSON.parse(toolJson); + + // For writeFile, ensure content is stringified if it's an object + if (toolRequest.tool === "writeFile" && toolRequest.args.content && typeof toolRequest.args.content === "object") { + toolRequest.args.content = JSON.stringify(toolRequest.args.content, null, 2); + } + const result = await this._executeToolRequest(toolRequest, workingDir); // Replace this specific tool block with its result